Fix A.new([[1,2],3]).flatten to return Array.

This commit is contained in:
Yukihiro "Matz" Matsumoto
2020-11-05 14:25:01 +09:00
parent 4e535080dc
commit d9bd77b180
+1 -1
View File
@@ -209,7 +209,7 @@ class Array
# a.flatten(1) #=> [1, 2, 3, [4, 5]]
#
def flatten(depth=nil)
res = dup
res = Array.new(self)
res.flatten! depth
res
end