Guest User

Untitled

a guest
Jan 21st, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. def flatten_array(array, result = [])
  2. return result << array.first if ((array.length == 1) && (array.first.is_a? Integer))
  3. array.each do |char|
  4. if char.is_a? Integer
  5. result << char
  6. else
  7. flatten_array(char, result)
  8. end
  9. end
  10. result
  11. end
Add Comment
Please, Sign In to add comment