Last active
June 24, 2016 21:58
-
-
Save edugonch/6d768671e344253864ffcb4150030f79 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
# 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