From: Robert Dober Date: 2007-02-16T06:44:18+09:00 Subject: Re: is it behaving strange ? On 2/15/07, dblack@wobblini.net wrote: > Hi -- > > On Fri, 16 Feb 2007, Robert Dober wrote: > > > Well I cannot speak for OP but what puzzles me is > > > > a=[42] # sorry 9 is not the number ;) > > *a ==> error # gotta check with 1.9 an 2.0 at home > > > > I would think that this expression can/could/should/might perfectly > > evaluate to 42 look at this other oddity the following code is > > completely legal and POLS(1) > > def x *args > > return *args > > end > > (1) in the sense that a,b,c = x 1,2,3 sets a to 1, b to 2 and c to 3 > > and x is a NOP > > > > but return in the last statement is optional, or is it not ;) I know > > you are not falling into my trap ! > > > > I see no reason however why > > def x *args > > *args > > end > > should not be legal > > I can't think of a case where you'd need it, since the arguments would > just get wrapped up in an array anyway. Agreed, but that was *not* my point > Also, *args is basically > equivalent to a bare list, and you can't do: > > def x > 1,2,3 > end > def x return 1,2,3 end is legal it all is about consistency 1,2,3 vs. return 1,2,3 *rhs vs. lhs = *rhs I have no idea if one could make it work without breaking a parsable syntax, I just thought that OP was doing a good job at pointing to this inconsistency. We could forbid return *a but can we forbid lhs = *rhs? I realize I am not smart enough to complain, - and too tired too :( -. But I also feel that I did not really underline the inconsistency in the syntax so far. An inconsistency that is not really troubling me but which is here nevertheless. Well that is pretty much what I wanted to say. Cheers Robert > > David > > -- > Q. What is THE Ruby book for Rails developers? > A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black) > (See what readers are saying! http://www.rubypal.com/r4rrevs.pdf) > Q. Where can I get Ruby/Rails on-site training, consulting, coaching? > A. Ruby Power and Light, LLC (http://www.rubypal.com) > > -- We have not succeeded in answering all of our questions. In fact, in some ways, we are more confused than ever. But we feel we are confused on a higher level and about more important things. -Anonymous