This file contains 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
# Extends Array class to include flatten_integer_array | |
# Method can be used in this manner: | |
# [1,2,3,4].flatten_integer_array | |
class Array | |
def flatten_integer_array output = [] | |
self.each do |a| | |
if a.is_a? Array | |
a.flat output | |
elsif a.is_a? Integer | |
output << a |