Version: v0.5.0 - Beta.  We welcome contributors & feedback.  THanks!

Map.default

default(value)

Description

Set the default value that will be returned when a missing key is accessed.

let numBirds = {}.default(0);

numBirds['cardinals'] += 1;
numBirds['bluejays'] += 2;

print(numBirds);
//= { cardinals: 1, bluejays: 2 }