+ 1
Ruby - Why is arr1.length = 3?
arr1 = ["a", "b"] arr2 = ["c","b","a"] arr1 << arr2 puts arr1 puts "#{arr1.length}" As expected, after <<, arr1 = ["a","b","c","b","a"]. Why arr1.length = 3, as if it were a set?
3 Answers
+ 2
actually, its ["a","b",["c","b","a"]]
+ 2
You should do arr1 += arr2
0
do something like this
for i in 0...arr2.length
arr1 << arr2[i]
end