On 8/17/07, Wiktor Ihárosi <[EMAIL PROTECTED]> wrote:
>
>
> I have checked the new prototype, and after a few hours I ran into a
> problem. It seems the method of Enumerable.include has been changed.
> It uses === operator instead of ==.


This is my fault from [7170]. I changed it to strict equality because
Enumerable#include uses Array#indexOf internally (if the enumerable is an
array). The latter (native) method uses strict equality (
http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:indexOf#Description),
while Ruby uses the normal equality operator for #include (
http://ruby-doc.org/core/classes/Enumerable.html#M003167).

Because we are following Ruby semantics for Enumerable#include, not
JavaScript semantics for #indexOf, this should be corrected. I have whipped
up the following patch: http://pastie.caboo.se/private/j7xeidwpb4jtfflrta

It changes the equality operator from strict to weak and adds unit tests for
this. The method still uses native #indexOf internally, but if the element
is not found using #indexOf it doesn't immediately return false, but still
performs the search using weak equality.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to