Go supports below type assertion <https://tour.golang.org/methods/15>

t := i.(T)
and 
t, ok := i.(T)

Can this feature be extended to array of interfaces as mentioned below?

t := i.([]T)
and 
t, ok := i.([]T)


I have been using Golang for almost four years and I have come across use 
cases requiring this feature many times. So far, I write a function for 
each specific case which clones the array into new array with type asserted 
to new type. I repeat the same pattern of assertion for array of different 
types and perform extra array copy each time I assert. Is there a better 
alternative solution with existing Go feature or Is there a chance that 
this feature will be supported in future?

sample code <https://play.golang.org/p/-Flgqk9qbJD>

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to