Back to Lo

Core Coalescemap

docs/data/core-coalescemap.md

1.53.0479 B
Original Source

Returns the first non-empty map from the provided arguments, with a boolean indicating if a non-empty map was found.

go
result, ok := lo.CoalesceMap(map[string]int{}, map[string]int{"a": 1}, map[string]int{"b": 2})
// map[string]int{"a": 1}, true

result, ok = lo.CoalesceMap(map[string]int{}, map[string]int{})
// map[string]int{}, false

result, ok = lo.CoalesceMap(map[int]string{}, map[int]string{1: "one"}, map[int]string{2: "two"})
// map[int]string{1: "one"}, true