daily pastebin goal
63%
SHARE
TWEET

Untitled

a guest Jan 24th, 2018 43 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def flatten(elements)
  2.   return [elements] if !elements.is_a?(Array)
  3.   elements.reduce([]){ |arr, e|  arr + flatten(e) }
  4. end
  5.  
  6. flatten [[1,2,[3]],4]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top