We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I think I have found an error in the language reference
https://processing.org/reference/IntDict_add_.html
IntDict inventory;
void setup() {
size(200, 200);
inventory = new IntDict();
inventory.set("cd",84);
inventory.set("tapes",15);
inventory.set("records",102);
println(inventory); // There are 84 cds
inventory.add("cds", 20);
println(inventory); // There are 104 cds
}
the add method add an element in the dictionnarie whereas the example said it sum the value to the existing key ...
Answers
The keys are different. One is cds the other is cd.
Method add()'s description's correct. It's the code itself which's wrong! :O)
Change
inventory.add("cds", 20);
toinventory.add("cd", 20);
.Otherwise, method add() behaves like set() when specified key entry doesn't exist yet! :-@
Unfortunately, Processing's reference got many errors & important omissions! X(
oh yes, you have already told me that "Processing's reference got many errors "
can't we change the code examle ?
https://GitHub.com/processing/processing-web-archive
this is an archive.
current place is there : https://github.com/processing/processing-docs
modification have been done :)
https://processing.org/reference/IntDict_add_.html
https://github.com/processing/processing-docs/issues/398#event-574684940