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 Mon, 20 Oct 2003 06:04:10 GMT
thank you very much for that hint - yes, not very elegant, but it works ...

Andreas


Zitiere Jim Ley <jim@jibbering.com>:

> 
> "Andreas Neumann" <neumann@karto.baug.ethz.ch> wrote in message
> news:1066499759.3f917eaf58e7f@karmail.ethz.ch...
> > > what you can do is:
> > >
> > > a=[]
> > > a['chicken']=whatever
> > > a.push(a['chicken'])
> > >
> > > for (i=0;i<a.length;i++) alert(a)
> >
> > ok, got that - works fine so far. But is there a way, while using
> your
> above
> > described for-loop to get at the same time the key of the associative
> array
> > back, that is corresponding with the value?
> 
> No, you'll have to create objects containing the name value
> 
> a=[]
> a['chicken']={key:'chicken',value:whatever}
> a.push(a['chicken'])
> 
> Then access them with a[0].key / a[0].value - but of course that's
> duplicating stuff.
> 
>  var fruits = new Array();
>  fruits["oranges"] = {key:'oranges',value:25};
>  fruits.push(fruits["oranges"]);
>  fruits["bananas"] = {key:'bananas',value:15};
>  fruits.push(fruits["bananas"]);
>  fruits["pineapples"] = {key:'pineapples',value:8};
>  fruits.push(fruits["pineapples"]);
> 
>  for (i=0;i<fruits.length;i++) {
>     alert(fruits[i].key+','+fruits[i].value);
>  }
> 
> Which is pretty nasty...
> 
> 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