You want the "splat" operator (unary asterisk):
*pool_map.keys.map{|val| ...}
Note that you don't need the collect
at the end there, it does nothing! collect
is just an alias for map
, and you aren't doing anything with it because you haven't passed it a block.
Splat is really useful for destructuring arrays:
arr = [1, 2, 3]
a, b, c = *arr
# a = 1; b = 2; c = 3
And you can often use it to supply arguments to methods, like you are trying to do
def sum_three_numbers(x, y, z)
x + y + z
end
arr = [1, 2, 3]
sum_three_numbers(*arr)
# => 6
arr = [1, 2]
sum_three_numbers(100, *arr)
# => 103