Name

hasKey()

Class

FloatDict

Description

Check if a key is a part of the data structure.

Examples

  • FloatDict inventory;
    
    void setup() {
      size(200, 200);
      inventory = new FloatDict(goods, amounts);
      inventory = new FloatDict();
      inventory.set("coffee",108.6);
      inventory.set("flour",5.8);
      inventory.set("tea",8.2);
      println(inventory);
      if (inventory.hasKey("flour") == true) {
        println("Yes, we have flour."); 
      } else {
        println("Sorry, no flour.");
      }
    }
    
    

Syntax

  • .hasKey(key)

Return

  • boolean