怎么把数组中的元素转化为参数来传递?

譬如:有一个方法:
def test_method *binvar
end

然后我有一个数组 data['p1','p2','p3','p4'......]

我怎么把data中的元素作为参数传递进去呢?

谢谢



问题补充

Hooopo 写道
加个星星就可以了


>> def test_method *args
>> p args
>> end
=> nil
>> test_method *[1,2,3]
[1, 2, 3]
=> nil
>> test_method [1,2,3]
[[1, 2, 3]]
=> nil
>>



非常感谢

加个星星就可以了

[code="ruby"]

def test_method *args
p args
end
=> nil
test_method *[1,2,3]
[1, 2, 3]
=> nil
test_method [1,2,3]
[[1, 2, 3]]
=> nil

[/code]