From: Pierre Lecocq Date: 2010-04-27T23:23:30+09:00 Subject: Re: Variable number of arguments for methods called with "send" Thanks a lot Brian. In fact, I didn't put the star before my args array. That is why it crashed when the method does not take arguments. Thanks again ! Brian Candler wrote: > Pierre Lecocq wrote: >> But if I want to call a method with arguments, I am stuck because I do >> not know how many arguments it needs and what is the "kind" of arguments >> (can be "static arguments" - arg1, arg2 - or VARGS - *args - ) > > There is no difference between those cases. > > args = [] > send(:foo, *args) > # same as: send(:foo) > > args = ["abc"] > send(:foo, *args) > # same as: send(:foo, "abc") > > args = ["abc","def"] > send(:foo, *args) > # same as: send(:foo, "abc", "def") > > HTH, > > Brian. -- Posted via http://www.ruby-forum.com/.