From: Ryan King Date: 2002-09-19T15:44:24+09:00 Subject: Re: If Statement Help and param passing On 2002.09.19, Matthew, Graeme wrote: > Thanks Ryan, no wonder I couldnt find any doco :-) doh ! , one more for the > day > > I have noticed that some params in methods / function are passed as follows: > > object.method(value, *data) > > is the * character serving a purpose here, eg passing by value rather than > reference ? This is the price we pay for using funny syntax here and there. =) In this case (specifically, when * is used as a unary operator), it is the "splat" operator. Or the "splatsterisk", if you will. (Most people won't). As an example: def foo a, b p a, b end foo *['don', 'key'] # Same as foo 'don', 'key' # ..this That is, it peels off the arrayness of the argument. Kind of funky, but it's your only recourse sometimes. And, in a preemptive strike, I'll answer this one: def bar first, *rest p first, rest end bar 1, 2, 3, 4 In this case, "*" is serving as an "unsplat" (or "unsplatserisk", but almost no one will). It allows you to pass an arbitrary number of arguments and they all get rolled into one array, in this case "rest". It's like C's varargs. - Ryan King P.S.: Sorry for using cliche` metasyntactic method names. I'm being lazy.