From: Robert Dober Date: 2006-10-27T06:12:32+09:00 Subject: Re: '**' as hash splat? ------=_Part_61002_15561418.1161897149604 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 10/26/06, Rick DeNatale wrote: > > 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. You are right about all you were saying, only I did not want to make any statements about that, I just wanted to underline that :[] was an instance method of Array as I did not think about Kalman's point . I thaught about the impact on an interested newbie reader. Was I too harsh/quick/offensive? If so I am sorry; I thaught it was an important minor point to make and I thaught I was quite alligned with Kalman's style but I have no problem in admiting errors ;) Cheers Robert -- > Rick DeNatale > > My blog on Ruby > http://talklikeaduck.denhaven2.com/ > > -- The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore all progress depends on the unreasonable man. - George Bernard Shaw ------=_Part_61002_15561418.1161897149604--