MCPcopy Create free account
hub / github.com/benbjohnson/immutable / ExampleMapBuilder_Set

Function ExampleMapBuilder_Set

immutable_test.go:1553–1571  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1551}
1552
1553func ExampleMapBuilder_Set() {
1554 b := NewMapBuilder[string, any](nil)
1555 b.Set("foo", "bar")
1556 b.Set("baz", 100)
1557
1558 m := b.Map()
1559 v, ok := m.Get("foo")
1560 fmt.Println("foo", v, ok)
1561
1562 v, ok = m.Get("baz")
1563 fmt.Println("baz", v, ok)
1564
1565 v, ok = m.Get("bat") // does not exist
1566 fmt.Println("bat", v, ok)
1567 // Output:
1568 // foo bar true
1569 // baz 100 true
1570 // bat <nil> false
1571}
1572
1573func ExampleMapBuilder_Delete() {
1574 b := NewMapBuilder[string, any](nil)

Callers

nothing calls this directly

Calls 3

MapMethod · 0.80
SetMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…