Skip to content

Instantly share code, notes, and snippets.

@edugonch
Last active June 24, 2016 21:58
Show Gist options
  • Save edugonch/6d768671e344253864ffcb4150030f79 to your computer and use it in GitHub Desktop.
Save edugonch/6d768671e344253864ffcb4150030f79 to your computer and use it in GitHub Desktop.
# arr.flatten ... Just kidding :)
def my_flatten arr
new_arr = []
arr.each do |el|
if el.is_a?(Array)
new_arr = my_union(new_arr, my_flatten(el))
else
new_arr << el
end
end
new_arr
end
def my_union arr1, arr2
arr2.each do |el|
arr1 << el
end
arr1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment