On 11.06.2007 02:17, Morton Goldberg wrote:
> I admit this is very clever.

Thank you. :-)

> But doesn't the user pay a rather high 
> runtime cost in return for the coder's enjoying a small dollop of 
> syntactic sugar? Integer#elements is a rather expensive function for 
> what it delivers.

Definitively.  You could optimize it by cashing those lambdas but that 
introduces some additional complexity, overhead and then again you waste 
more memory and...

> Does no one recall what the late Alan Perlis wrote in 
> 1982 [*]:
> 
>     A LISP programmer knows the value of everything, but the cost of 
> nothing.

:-)

> Should Ruby programmers vie for the same notoriety?
> 
> I realize you were only having a little fun and sharing your fun with 
> the mailing list. But when others start proposing an RCR along these 
> lines I get scared.
> 
> Regards, Morton
> 
> [*] No. 55 in <http://www.cs.yale.edu/quotes.html>.

I would not promote this for regular use as there is also the much more 
efficient other form of "case" which can be utilized to solve this in a 
more "natural" (?) and also more efficient manner:

case
   when a.size == 3
     ...
   when a[0] == "foo"
     ...
   else
     ...
end

Kind regards

	robert