Name

add()

Class

IntDict

Description

Add to a value. If the key does not exist, an new pair is initialized with the value supplied.

Examples

  • 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("cd", 20);
      println(inventory);  // There are 104 cds
    }
    
    

Syntax

  • .add(key, amount)

Return

  • void