-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jean-Philippe Encausse wrote:
> A little question about each() function:
> function test() {
>   $H(hashtable).each(function(entry,idx){   /* code */  });
> }
> 
> In my /*code*/ I can do
> - throw $continue
> - throw $break
> 
> But can I do a return xxx ?
Yes, it will have the same effect as (the already obsolete)
"throw $continue".

> It seems the loop didn't ends ? Is it normal ?
OFC it's normal. Remember that "your code is outside of the loop scope: the
looping code happens behind the scene". Yes, I was quoting the docs:
 http://prototypejs.org/api/enumerable/each

Jean-Philippe, should I suppose you were trying to use "each -> return"
hoping for a "filter"? That's plain wrong, you should use "grep", "find" or
"findAll" for such things. For example, to filter out "false" values you
could use:
  $H({ a:0, b:1, c:0, d:3 }).findAll(function(x){ return x.value })
  // returns: [["b", 1], ["d", 3]]


BTW, folks, we need a documentation update, telling people there is no
"throw $continue" in Enumerables from starters, in order to avoid any
confusion when they will update to a newer version which won't support that
for good (yes, Sam already dropped it in SVN).

- --
Marius Feraru
-----BEGIN PGP SIGNATURE-----

iD8DBQFFwdPPtZHp/AYZiNkRAhziAKCiCXt7ThBdL6TM8kduCmVh6l2fdwCgyfuT
mYMLYeq2KWfaXbMh6pNjQ0Y=
=0ILK
-----END PGP SIGNATURE-----

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" 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/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to