xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andreas Neumann <neum...@karto.baug.ethz.ch>
Subject Re: Strange behaviour of Rhino with associative array object
Date Sat, 18 Oct 2003 15:32:40 GMT
ok - I do understand that the sorting in associative arrays is implementation
specific

but what alternative do I have to the "for .. in" loop. How can I step through
all elements of an associative array withouth using "for .. in"

Or should I avoid using associative arrays at all? Would be bad news. I am quite
used to associative arrays, coming from perl/PHP

apologize if that is a stupid question. I am not a good programmer ...

Thanks for ideas on that issue,
Andreas


Zitiere Jim Ley <jim@jibbering.com>:

> 
> "Andreas Neumann" <neumann@karto.baug.ethz.ch> wrote in message
> news:1066454983.3f90cfc71e4ee@karmail.ethz.ch...
> 
> > Later on I use a "for ... in" loop to extract the values of the
> associative
> > array.
> 
> This isn't really safe, because things in the prototype also can get
> enumerated so if I do:
> 
> Array.prototype.chicken=function() {alert('a') }
> 
> n=[]
> n['a']=1
> 
> for (i in n) alert(i)
> 
> will alert a and chicken
> 
> > It appears that the Rhino js engine automatically sorts
> alphabetically
> > according to the index value, which means, that "Asians" come first,
> then
> "
> > Blacks", ....
> 
> Perfectly valid behaviour, there's no reliability on the ordering, it's
> implementation specific, I'd recommend rewriting to avoid needing for i
> in a
> syntax.
> 
> Jim.
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
> 
> 



--     
The only thing that stands between a man and what he wants from
life is often merely the will to try it and the faith to believe
that it is possible ...
-- M. DeVos
    
----------------------------------------------     
Andreas Neumann - Department of Cartography     
Swiss Federal Institute of Technology (ETH)     
ETH Hoenggerberg, CH-8093  Zurich, Switzerland     
Phone: ++41-1-633 3031, Fax: ++41-1-633 1153     
e-mail: neumann@karto.baug.ethz.ch     
www: http://www.karto.ethz.ch/neumann/     
SVG.Open/Carto.net: http://www.svgopen.org/     

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Mime
View raw message