Created
June 29, 2017 03:05
-
-
Save awilkening/ccadfbfcdd0fa492d0753288479bcfdc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def smush(array, container = []) | |
array.each do |element| | |
if element.is_a? Array | |
smush element, container | |
else | |
container << element | |
end | |
end | |
container | |
end | |
if smush([[1,2,[3]],4]) == [1,2,3,4] | |
puts "Smushed" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment