On 4 Dec, 2007, at 8:23 AM, John-David Dalton wrote:
> The "map" method is passing 2 params to the iterator.
> This makes the Element.next() go nuts cause its second param is used
> for sibling offset.
>
> In PHP array_map only passes the "value" and not the index.
> It makes since for Enumerable.each() to send both, but I think map
> should be left to just the value. I image there are more cases where
> this sort or error would occur.
I believe this is a result of trying to make each and map adhere more
closely to the JavaScript 1.6 enumeration methods for Arrays which
pass 3 arguments: the value, the index, and the original array.
This is a case were you'll just need an adapter method. Silly as it
seems, this will work fine:
function(element){ return Element.next(element); }
This issue highlights an instance where better documenting the
prototype of the iterator function would help (as recently mentioned
in an email to this list). If the documentation clearly stated that
the iterator function should accept 3 arguments, you wouldn't have
tried to use Element.next as an iterator without an adapter.
--
Jeff Watkins
ui wrangler
online apple store
The online store is looking for a JavaScript superstar with a strong
software engineering background. Is that you? Drop me an email if
you're interested.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype: Core" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---