From: Max Williams Date: 2009-07-23T18:14:50+09:00 Subject: Re: Ruby "star".... what's it? Mirko Viviani wrote: > Hi everybody. > What means this snippet of code? Why use the "star" ? > > myarray = [1,2,3,4,5,6,6] > qa = *myarray > > Thank you. In this example it doesn't really do anything, i think. Normally you would use the * in an argument list, in a method definition, to effectively say 'pull all arguments after this into a single array', eg >> def foo(mainarg, *otherargs) >> puts mainarg.inspect >> puts otherargs.inspect >> end => nil >> foo(1,2,3,4,5,6) 1 [2, 3, 4, 5, 6] => nil In this sense it's like * in a regular expression, meaning 'any number of arguments'. That's how i understand it anyway, a more precise description will probably be forthcoming :) -- Posted via http://www.ruby-forum.com/.