For example, if there is a builtin convertible(from, to) constraint,
We can define a slice conversion function as
func Convert(type Ta, Tb converitble(Ta, Tb)) (avs []Ta, _Tb) (bvs []Tb) {
bvs = make([]Tb, 0, len(avs)
for _, v := range avs {
bvs = append(bvs, Tb(v))
}
return bvs
}
We can use it as:
iValues := Convert([]int{}{1, 2, 3}, interface{}(nil))
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/e67fe1cd-888c-4828-ba6f-0fd8e47b58d9o%40googlegroups.com.