Menu

#50 Tuples don't have equals and hashCode defined

open
nobody
None
5
2006-10-22
2006-10-22
B S
No

- therefore they don't work if you use them as keys in
a HashMap (thats how I ran into it). Example:

package bug;
void main(String[] args){
let a = new HashMap();
a.put((1,2),10);
println(a);
println(a.get((1,2)));
}

prints

{[Ljava.lang.Object;@19821f=10}
null

Apparently tuples are implemented with arrays. If it is
too much trouble or isn't worth it to change it from
being arrays to a specialized object, it should be
clearer that they are just arrays.

Discussion


Log in to post a comment.

MongoDB Logo MongoDB