ugly, but how do I do this?

Oct 17, 2006 at 7:30pm

ugly, but how do I do this?

I have an Atom[] in a TreeMap, which is also in a TreeMap!! I told you it was ugly…

Is there a one-liner to change a single value at an index in the Atom[]?

I understand that:

map1.get(key1).get(key2)

can pull out my Atom[], but can I get the Atom at a given index as well? I tried:

map1.get(key1).get(key2)[1] = something-that’s-an-Atom;

But that didn’t work… it’s getting an object when it wants an array. I understand it needs to be cast somewhere, but where?

J.

#28218
Oct 17, 2006 at 8:17pm

> map1.get(key1).get(key2)[1] = something-that’s-an-Atom;
>
> But that didn’t work… it’s getting an object when it wants an array. I understand it needs to be cast somewhere, but where?

try

((Atom [])(map1.get(key1).get(key2)))[1]

Ben

#86401
Oct 17, 2006 at 9:51pm

geez… I don’t know how long it would have taken me to figure that out, but you know what happens when you put a monkey at a macbook…

thanks, Ben.

J.

#86402

You must be logged in to reply to this topic.