On Feb 17, 5:03 pm, Daryl Stultz <[email protected]> wrote:
> On Tue, Feb 16, 2010 at 11:14 AM, jg <[email protected]> wrote:
> > Hi all,
>
> > sorry if this question is trivial... but I don't know how to deal with
> > this in js, and specifically in rhino shell...
>
> > Say, I have an enum like
> >    enum Cardsuit { CLUBS, DIAMONDS, SPADES, HEARTS }
>
> > how do I use it in Rhino?
>
> > Well, this is how I use them, which may not be what you want since it puts
>
> the values at the top level. Before running the script:
>
> ScriptableObject.*putProperty*(scope, "CLUBS", Context.*javaToJS*(Cardsuit.*
> CLUBS*, scope));

That's obviously a solution. But it would be nice (and I think that's
what the original poster meant) to have a pure JS solution that works
via Rhino's Java class wrapper. The obvious solution would be to
expose enum values as properties of the enum class, e.g.
Cardsuit.CLUBS (or actually OuterClass[$|.]Cardsuit.CLUBS).

Hannes

> --
> Daryl Stultz
> _____________________________________
> 6 Degrees Software and Consulting, Inc.http://www.6degrees.com
> mailto:[email protected]

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

Reply via email to