I don't think this is possible. In Ruby you can do:
class Foo
include Enumerable
def each
yield 3
yield 2
yield 1
end
end
And it knows how to 'pause' the method after a yield and resume next time you call #next. There's no way to simulate this in JavaScript without using generators, which aren't widely supported.
Anthony Rowlands
unread,
Jan 11, 2012, 6:36:43 PM1/11/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to jsclas...@googlegroups.com
Interesting... I looks like Iterators and Generators were introduced to JavaScript in version 1.7 (2008!). And support is still so poor that you haven't used them? How lame...
Anthony Rowlands
unread,
Jan 11, 2012, 6:53:02 PM1/11/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message