On Jan 30, 6:05 pm, Brad <bradavo...@gmail.com> wrote:
> Why does Hash#filter return an Array instead of a Hash? It isn't
> really a filter if it's returning another data type.
>
> Instead of
>         $H({'a':1,'b':2,'c':3,'d':4}).filter(function(i) { return i.value %
> 2; })
> that returns,
>         [["a", 1], ["c", 3]]
> I would expect it to return
>         {"a": 1, "c": 3}

This is the behavior of Ruby's (1.8) hashes - some of the enumerable
methods return array rather than hash. It was considered a bug and was
fixed in a recently released Ruby 1.9. IIRC, there should be an old
ticket somewhere on the old bug tracker with a lengthy discussion
about this issue.

--
kangax
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to