RosettaCodeData/Task/Associative-array-Creation/Ecstasy/associative-array-creation-...

8 lines
262 B
Plaintext

Int? mightBeNull = map["foo"];
Int neverNull = map.getOrDefault("foo", 0);
if (Int n := map.get("foo")) {
// if "foo" is in the map, then the variable "n" is set to its value
} else {
// if "foo" is not in the map, then the variable "n" is not defined
}