From: Jean-Hugues ROBERT Date: 2002-04-26T22:56:56+09:00 Subject: Re: $_ if no |var| At 22:59 25/04/2002 +0900, Lars Christensen wrote: > [7,3,1,7,8,2,3,2].sort { |a,b| a <=> b }.map { |a| a**2 } >This is more readable IMO: > [7,3,1,7,8,2,3,2].sort { a <=> b }.map { a**2 } >I like this implicit stuff at work here, but I would perhaps create too >much conflict with other variables? How about allowing the |n| to be put >anywhere in the block?: > [7,3,1,7,8,2,3,2].sort { |a| <=> |b| }.map { |a|**2 } >-- >Lars Christensen, larsch@cs.auc.dk Very nice indeed. When is binding resolved, compile or run time ? p = proc { if |a| then |c| else |b| end } Ex: A) p.call( 1, 2, 3) => 2 B) p.call( nil, 2, 3) => 2 or 3 ? I would prefer 3. This implies that binding of params to variables is done at compile time. On the contrary, if |x| semantic is to "consume" the "next" parameter (at runtime) then b would be assigned 2 and that is weird. BTW: Handling the |p,| construction that I discovered today (thanks Matz) is adding another challenge. Jean-Hugues ------------------------------------------------------------------------- Web: http://hdl.handle.net/1030.37/1.1 Phone: +33 (0) 4 92 27 74 17