Hi --

On Fri, 28 Aug 2009, Rick DeNatale wrote:

> Now, is the Ruby or Smalltalk approach 'better'  I guess if I had my
> druthers, I guess I differ a bit from my friend David A. Black here,
> and I'd prefer it if Ruby were a bit more Smalltalk like here, and
> Ruby 1.9 has made some steps in that direction.
>
> But it is what it is.

The problem is that it isn't what it is :-) Maybe it's just Hash
that's special-cased. It's certainly impossible to return, say, a file
handle from doing fh.map, meaningless to return a range from
range.map (though range.map is sort of hybrid behavior anyway), and
maybe or maybe not meaningful for other classes, including
user-defined ones, to return an object of the same class.

I guess I like the simplicity of defining each, including Enumerable,
and getting pre-defined behavior. I know that Hash and Array already
override a few things, though, so it's never been quite that simple.
Still, given the underlying mechanism, there's no way to generalize
returning a same-class object.


David

-- 
David A. Black / Ruby Power and Light, LLC / http://www.rubypal.com
Q: What's the best way to get a really solid knowledge of Ruby?
A: Come to our Ruby training in Edison, New Jersey, September 14-17!
    Instructors: David A. Black and Erik Kastner
    More info and registration: http://rubyurl.com/vmzN