Version: v0.6.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.

$numBirds = {}.default(0);

$numBirds['cardinals'] += 1;

$numBirds['bluejays'] += 1;
$numBirds['bluejays'] += 1;

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