name, slug, sourceRef, category, subCategory, signatures, variantHelpers, similarHelpers, position
name
slug
sourceRef
category
subCategory
signatures
variantHelpers
similarHelpers
position
MapToSliceErr
maptosliceerr
map.go#L379
core
map
func MapToSliceErr[K comparable, V any, R any](in map[K]V, iteratee func(key K, value V) (R, error)) ([]R, error)
core#map#maptosliceerr
core#map#maptoslice
core#map#mapentrieserr
core#slice#maperr
215
Transforms a map into a slice by applying an predicate to each key/value pair. Returns an error if the iteratee function fails, stopping iteration immediately.
m:=map[int]int64{1:4,2:5,3:6}s,err:=lo.MapToSliceErr(m,func(kint,vint64)(string,error){ifk==2{return"",fmt.Errorf("key 2 not allowed")}returnfmt.Sprintf("%d_%d",k,v),nil})// []string(nil), error("key 2 not allowed")