Files
lo/docs/data/it-keyby.md
T
2025-10-08 14:55:05 +02:00

578 B

name, slug, sourceRef, category, subCategory, signatures, playUrl, variantHelpers, similarHelpers, position
name slug sourceRef category subCategory signatures playUrl variantHelpers similarHelpers position
KeyBy keyby it/seq.go#L398 it sequence
func KeyBy[K comparable, V any](collection iter.Seq[V], transform func(item V) K) map[K]V
it#map#associate
core#slice#keyby
core#slice#associate
15

Transforms a sequence into a map using a transform function to generate keys.

result := it.KeyBy(it.Range(1, 5), func(item int) string {
    return fmt.Sprintf("key-%d", item)
})
// map[string]int{"key-1": 1, "key-2": 2, "key-3": 3, "key-4": 4}