Version: v0.7.0 - Beta.  We welcome contributors & feedback.

Map.default

default($value) -> self

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 }

See Also