From: Rick DeNatale Date: 2006-10-26T07:03:43+09:00 Subject: Re: '**' as hash splat? On 10/25/06, Robert Dober wrote: > On 10/24/06, Kalman Noel wrote: > > > > Ken Bloom: > > > On Mon, 23 Oct 2006 20:49:55 -0700, Trans wrote: > > >> a = [2,1] > > >> [3,*a] #=> [3,2,1] > > > The purpose of splat is to convert an array into a list of parameters to > > a > > > method. Since [] is a method, > > > > irb> method :[] > > NameError: undefined method `[]' for class `Object' > > Maybe you want to try this > > Array.instance_method :[] But I think that Kalman's point wasn't that there are no :[] methods, which of course there are, but that the snippet [3, *a] Isn't a method call but syntax. And adding to that, splat isn't just for method parameters, but for cases like this as well as parallel assignment. And I think of splat as primarily a parallel assignment 'thing' since both argument passing and literal construction can be viewed as usages of parallel assignment. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/