Files
lo/docs/data/core-coalescemap.md
T
2025-10-06 17:15:49 +02:00

964 B

name, slug, sourceRef, category, subCategory, signatures, playUrl, variantHelpers, similarHelpers, position
name slug sourceRef category subCategory signatures playUrl variantHelpers similarHelpers position
CoalesceMap coalescemap type_manipulation.go#L196 core type
func CoalesceMap[K comparable, V any](v ...map[K]V) (map[K]V, bool)
https://go.dev/play/p/Gyo9otyvFHH
core#type#coalescemap
core#type#coalesce
core#type#coalesceorempty
core#type#coalesceslice
core#type#coalescesliceorempty
core#type#coalescemaporempty
core#type#empty
150

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

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