Skip to content

Instantly share code, notes, and snippets.

@drKreso
Last active October 24, 2016 20:40
Show Gist options
  • Select an option

  • Save drKreso/c94ac33a17976134a5efa9b0224a87fd to your computer and use it in GitHub Desktop.

Select an option

Save drKreso/c94ac33a17976134a5efa9b0224a87fd to your computer and use it in GitHub Desktop.
Flat array method
```ruby
def make_flat(array, result = [])
array.each do |item|
item.class == Array ? make_flat(item, result) : result << item
end
result
end
puts make_flat([[1,2,[3]],4,[[4,6]]]) == [1,2,3,4,4,6]
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment