Is there a way to break apart an array to use it as arguments to
another method? I would've sworn I've seen it, but I can't recall how
to do it.
Take the idea of trying to prepend to an array using unshift.
george=Array.new(10,0)
=> [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
george.unshift(1,1,1,1,1,1,1,1,1,1)
=> [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
#silly
george.unshift(Array.new(10,2))
=> [[2, 2, 2, 2, 2, 2, 2, 2, 2, 2], 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0]
#close-ish
george.unshift(Array.new(10,3)).flatten!
=> [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
#works, but it just feels wrong
Thanks,
Kyle