mirror of
https://github.com/samber/lo.git
synced 2026-04-22 23:47:11 +08:00
782 B
782 B
name, slug, sourceRef, category, subCategory, signatures, variantHelpers, similarHelpers, position
| name | slug | sourceRef | category | subCategory | signatures | variantHelpers | similarHelpers | position | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| FromSlicePtr | fromsliceptr | type_manipulation.go#L85 | core | type |
|
|
|
115 |
Converts a slice of pointers to a slice of values. Nil pointers are converted to zero values.
a, b, c := 1, 2, 3
ptrs := []*int{&a, &b, &c}
slice := lo.FromSlicePtr(ptrs)
// []int{1, 2, 3}
a, b = "hello", "world"
ptrs = []*string{&a, nil, &b}
slice = lo.FromSlicePtr(ptrs)
// []string{"hello", "", "world"} (nil pointer becomes zero value)
ptrs = []*int{}
slice = lo.FromSlicePtr(ptrs)
// []int{}