Skip to content

Instantly share code, notes, and snippets.

@mrdougwright
Created February 16, 2017 04:50
Show Gist options
  • Save mrdougwright/4283d01e584f9fca747b616e2874345e to your computer and use it in GitHub Desktop.
Save mrdougwright/4283d01e584f9fca747b616e2874345e to your computer and use it in GitHub Desktop.
Flatten an array of an arbitrary amount of arrays.
def make_flat(arr, flat_arr=[])
arr.each do |el|
el.is_a?(Array) ? make_flat(el, flat_arr) : flat_arr.push(el)
end
flat_arr
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment