<< keys | Dictionaries | numEntries >> |
value = lookup(d, key) |
value = lookup(d, key, 'FallbackValue', fallback) |
scalar: dictionary object.
key type must match or be convertible to the data type of keys in d.
scalar: Fallback value
value.
value = lookup(d, key) retrieves the value associated with the given key in dictionary d.
If the key does not exist, an error is raised.
value = lookup(d, key) is equivalent to value = d[key].
value = lookup(d, key, 'FallbackValue', fallback) specifies a fallback value to return if the key is not found in d.
lookup function only validates the fallback if it is needed. An error is raised only if the key is not found and no valid fallback is provided.
names = ["Apple" "Banana" "Kiwi"];
wheels = [1 2 3];
d = dictionary(wheels, names)
v = lookup(d,[3,5], 'FallbackValue', "Orange")
Version | Description |
---|---|
1.5.0 | initial version |
Allan CORNET