From: Michael Fellinger Date: 2007-06-21T19:46:21+09:00 Subject: Re: Behaviour of Enumerables reject vs. select mixed into Hash On 6/21/07, dblack@wobblini.net wrote: > Hi -- > > On Thu, 21 Jun 2007, Robert Dober wrote: > > > On 6/21/07, dblack@wobblini.net wrote: > >> Hi -- > >> > >> > >> > > >> > I fail to see why, could you give an example? > >> > >> Anything that depends on the output having array-like behaviors: > >> > >> selected = enum.select(&select_block).flatten > > That is ok, but we are complaining about > > > > hash.select > > > > Please note that the notion of Enumerable#select is erroneous in this > > thread, sorry for being blunt Alexander but you were talking about > > Hash#select the whole time. > > Yes, but making a special case of Hash, as opposed to other > enumerables, is exactly what breaks duck typing. I would actually > prefer to see Hash#reject return an array. > > > I think this would be a picture case for breaking backwards > > compatibility in Ruby2.0 > > Hash#select --> returning a Hash > > and we would live in a better world ;) > > unless you do not like it of course. > > > > In other words it might be interesting to know if people like this > > behavior without thinking about backwards compatibility or > > implementation details. > > I like having arrays be the "common currency" of select operations. I > don't think there's anything that you're prevented from doing as long > as that's the case. > So what, making #reject return an Array as well? > > David > > -- > * Books: > RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242) > RUBY FOR RAILS (http://www.manning.com/black) > * Ruby/Rails training > & consulting: Ruby Power and Light, LLC (http://www.rubypal.com) > >