I'm trying to implement a custom iterator and want to return different
values depending on the method of iteration (for..in or for each..in).
The problem is that my __iterator__ function receives the "onlyKeys"
parameter as being always true regardless of the for loop used.
So in Rhino 1.7 release 2 2009 03 22 on Windoes XP SP3 with Java
1.6.0_13, I have this test case:
var foo = {
__iterator__ : function(onlyKeys) {
print(keys);
yield [0, "a"];
}
};
for each (let f in foo) {}
for (let f in foo) {}
git-svn-id: svn://10.0.0.236/trunk@257257 18797224-902f-48f8-a5cc-f745e15eee43
12 lines
219 B
Plaintext
Executable File
12 lines
219 B
Plaintext
Executable File
js> version(170)
|
|
0
|
|
js> var foo = {
|
|
> __iterator__ : function(onlyKeys) {
|
|
> print(onlyKeys);
|
|
> yield [0, "a"];
|
|
> }
|
|
> };
|
|
js> for each (let f in foo) {}
|
|
false
|
|
js> for (let f in foo) {}
|
|
true |