Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def flatten_array(array, result = [])
- return result << array.first if ((array.length == 1) && (array.first.is_a? Integer))
- array.each do |char|
- if char.is_a? Integer
- result << char
- else
- flatten_array(char, result)
- end
- end
- result
- end
Add Comment
Please, Sign In to add comment