diff --git a/core/src/processing/data/FloatDict.java b/core/src/processing/data/FloatDict.java index 9647dfd67..eafa0943d 100644 --- a/core/src/processing/data/FloatDict.java +++ b/core/src/processing/data/FloatDict.java @@ -276,7 +276,18 @@ public class FloatDict { */ public float get(String key) { int index = index(key); - if (index == -1) return 0; + if (index == -1) { + throw new IllegalArgumentException("No key named '" + key + "'"); + } + return values[index]; + } + + + public float get(String key, float alternate) { + int index = index(key); + if (index == -1) { + return alternate; + } return values[index]; } diff --git a/core/src/processing/data/IntDict.java b/core/src/processing/data/IntDict.java index 749a2562a..5b3efedbe 100644 --- a/core/src/processing/data/IntDict.java +++ b/core/src/processing/data/IntDict.java @@ -298,10 +298,20 @@ public class IntDict { */ public int get(String key) { int index = index(key); - if (index == -1) return 0; + if (index == -1) { + throw new IllegalArgumentException("No key named '" + key + "'"); + } return values[index]; } + + public int get(String key, int alternate) { + int index = index(key); + if (index == -1) return alternate; + return values[index]; + } + + /** * Create a new key/value pair or change the value of one. * diff --git a/core/src/processing/data/StringDict.java b/core/src/processing/data/StringDict.java index a5eb53c10..76021173c 100644 --- a/core/src/processing/data/StringDict.java +++ b/core/src/processing/data/StringDict.java @@ -246,6 +246,14 @@ public class StringDict { return values[index]; } + + public String get(String key, String alternate) { + int index = index(key); + if (index == -1) return alternate; + return values[index]; + } + + /** * @webref stringdict:method * @brief Create a new key/value pair or change the value of one