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
#!/usr/bin/env ruby | |
# https://gist.github.com/hoanga/4955d1da5479dbff12c3eb33b9d26107 | |
# Returns a flattened version of all elements in the array. Same as Array.flatten | |
def my_flatten(arr) | |
result = [] | |
arr.each do |elem| | |
if elem.kind_of?(Array) | |
result.concat(my_flatten(elem)) |
OlderNewer