Guest User

Untitled

a guest
Jun 24th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.19 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2.  
  3. def flatten(array)
  4. array.each_with_object([]) do |e, flat|
  5. flat.push *(e.is_a?(Array) ? flatten(e) : e)
  6. end
  7. end
  8.  
  9. print flatten([[1, 2, 3, 4], 5, 6, [[7, 8], 9, 0]])
Add Comment
Please, Sign In to add comment