mirror of
https://github.com/samber/lo.git
synced 2026-04-22 23:47:11 +08:00
800 B
800 B
name, slug, sourceRef, category, subCategory, signatures, variantHelpers, similarHelpers, position
| name | slug | sourceRef | category | subCategory | signatures | variantHelpers | similarHelpers | position | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ToAnySlice | toanyslice | type_manipulation.go#L107 | core | type |
|
|
|
126 |
Converts a typed slice to a slice of empty interface values (any). This is useful when working with heterogeneous data.
ints := []int{1, 2, 3}
result := lo.ToAnySlice(ints)
// []any{1, 2, 3}
strings := []string{"a", "b", "c"}
result = lo.ToAnySlice(strings)
// []any{"a", "b", "c"}
custom := []struct{ Name string }{{Name: "Alice"}, {Name: "Bob"}}
result = lo.ToAnySlice(custom)
// []any{struct{ Name string }{Name: "Alice"}, struct{ Name string }{Name: "Bob"}}