From: Lloyd Zusman Date: 2001-03-31T23:10:04+09:00 Subject: [ruby-talk:13385] Re: Passing an array to `exec'? "Hee-Sob Park" writes: > "Lloyd Zusman" wrote in message > news:ltofuiikge.fsf@asfast.com... > > > > [ ... ] > > How about this? > > cmd = ['/bin/ls',*ARGV] > exec(*cmd) Thank you, that works fine! I never tried it with the `*' before `ARGV'. Unless I overlooked something, I couldn't find an explanation for `*' (as used above) anywhere in "Programming Ruby", which only discusses it in the following context: def varargs(a, *b) [ a, b ] end varargs 1 -> [ 1, [] ] varargs 1, 2 -> [ 1, [ 2 ] ] varargs 1, 2, 3 -> [ 1, [ 2, 3 ] ] The above example shows `*' being used within a method definition, not a method invocation, and I'd like to understand the exact meaning of `*' when used this way in the argument list of a *call* to a method. Does it mean this: "append the following array as a series of arguments to the set of arguments that are being passed to the method whose parameter list I appear in"? That would explain why it works here: cmd = ['/bin/ls', *ARGV] .. because the [] operator actually represents an invocation of a method. Is what I wrote here a correct explanation of `*' in this context? Thanks to all of you for your help. -- Lloyd Zusman ljz@asfast.com