On Jul 22, 3:33 am, Daniel Friesen <[email protected]> wrote:
> Norris Boyd wrote:
> > On May 21, 10:03 am, "Ionut G. Stan" <[email protected]> wrote:
> >> Hi,
>
> >> 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) {}
>
> >> The above will print true for both cases whereas the following (tested
> >> in Firefox 3.0.10) works as expected.
>
> >>     <script type="application/javascript;version=1.7">
> >>     var foo = {
> >>         __iterator__ : function(onlyKeys) {
> >>             alert(keys);
>
> >>             yield [0, "a"];
> >>         }
> >>     };
>
> >>     for (let f in foo) {}
> >>     for each (let f in foo) {}
> >>     </script>
>
> >> Am I doing something wrong or is it a (known) bug? Hopefully, I'm
> >> doing something wrong.
>
> >> Cheers
>
> > Yes, this is a bug. I've just committed a fix to CVS:
> > ScriptRuntime.java version 1.312.
>
> > --N
>
> This fix does not appear to be working. I found out that my array
> __iterator__ was broken in Rhino while working on MonkeyScript. I
> checked out cvs and testing my code and this code still fails. onlyKeys
> is always true even when using for each.
>
> --
> ~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]

Sorry the fix didn't work for you. Can you post a shell session that
shows the failure, or even better open a bug?

--N
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to