Skip to content

Instantly share code, notes, and snippets.

@carsoncole
Last active Apr 14, 2016
Embed
What would you like to do?
Ruby method that flattens arbitrary number of nested arrays of integers.
def self.flatten(array)
array.to_s.gsub(/[\[\]]/,'').split(/\s*,\s*/).map { |x| x.to_i }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment