[Gambas-devel] Collection bug (or strange behavior)

Robert Rowe robert.c.rowe at ...176...
Sun Mar 30 19:09:28 CEST 2008


Try this:

dim col as new collection

col.add("somevalue","aaa")
col.add("someothervalue","aaa") '<-- does not cause an error, it just 
overwrites "aaa"
print col["aaa"] '<-- result is someothervalue because the second line 
overwrote the value without an error

I would think that attempting to add an element whose key already exists 
should cause an error.

Similarly, attempting to remove an entry that does not exits does not 
raise an error. I'd think that this could lead to some rather subtle 
bugs in a program that could be rather hard to detect.

Robert Rowe





More information about the Devel mailing list