Good point about missing the binding for variables outside of the
block when using instance_eval :)

Indeed, i could alias :s :select. I'm still wondering why aliasing
those methods in Enumerable didn't help. It's not even related to the
original topic, but i have a general interest as of why didn't it
work...

Jarmo

On Feb 26, 10:13  䮮
> Jarmo Pertman wrote in post #984005:
>
> > When analyzing the differences between Scala and Ruby in that concrete
> > example then i can see that Scala "wins" by automatically initializing
> > local variable "_" in the context of "block".
>
> Setting _ with block arguments is pretty ugly, especially if the block
> takes multiple arguments (you'd get an array). It's like Perl's $_ which
> Ruby unfortunately inherits for gets.
>
> Your instance_eval solution changes the object context; code in your
> block would not be able to use instance variables or methods of the
> object to which the enclosing method belongs, which would be a major
> stumbling block for anything other than the simple cases you give.
>
> If you want to make the code shorter than scala, you could always alias
> :s :select
>
> :-)
>
> --
> Posted viahttp://www.ruby-forum.com/.