On Nov 27, 3:26 am, "Johan Compagner" <[EMAIL PROTECTED]> wrote:
> if i remember correctly shift() on a nativejavaarray works differently then
> on an NativeArray (js array)
> I think way back i did patch that in our code of rhino so that those things
> behave the same (like in my eyes it should)
>
> johan
>
> On Thu, Nov 27, 2008 at 00:43, [EMAIL PROTECTED] <[EMAIL PROTECTED]>wrote:
>
> > I'm a newbie to Rhino.  Recently I'm encountering a problem when using
> > shift() js method on an array-like variable, the length of the array
> > is never reduced by one.  Is it a bug or somethinig wrong with the way
> > I use shift()?  That array-like variable is obtained from Java.  So I
> > guess that's why its type is NativeJavaArray (on java side).
>
> > Thanks for any help.
> > _______________________________________________
> > dev-tech-js-engine-rhino mailing list
> > [EMAIL PROTECTED]
> >https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Is this what you're talking about:

js> var a = java.lang.reflect.Array.newInstance(java.lang.String,10);
js> a
[Ljava.lang.String;@181edf4
js> for (var i=0; i<10; i++) a[i] = i;
9
js> for (var i=0; i<10; i++) print(a[i])
0
1
2
3
4
5
6
7
8
9
js> a.shift()
0
js> a.length
10

The problem is that Java arrays, unlike JavaScript arrays, are created
with immutable length.

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

Reply via email to