mirror of
https://github.com/samber/lo.git
synced 2026-04-22 23:47:11 +08:00
570 B
570 B
name, slug, sourceRef, category, subCategory, playUrl, variantHelpers, similarHelpers, position, signatures
| name | slug | sourceRef | category | subCategory | playUrl | variantHelpers | similarHelpers | position | signatures | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ValueOr | valueor | map.go#L97 | core | map | https://go.dev/play/p/bAq9mHErB4V |
|
|
50 |
|
Returns the value for a key or a fallback if the key is not present.
value := lo.ValueOr(map[string]int{"foo": 1, "bar": 2}, "foo", 42)
// 1
value = lo.ValueOr(map[string]int{"foo": 1, "bar": 2}, "baz", 42)
// 42