On Tue, Jun 18, 2024 at 5:43 PM Ian Spence <ian.d.spe...@gmail.com> wrote:
>
> I've encountered a limitation and I'd like to understand what's going on and 
> why it's not working the way I would expect.
>
> If I have a slice of an interface type, and another slice of a type that 
> implements that interface, I cannot concat these slices together using append 
> - but I can add each item one by one.
>
> I would expect that interface implementations would also apply to slices, but 
> it looks like it doesn't?

That is correct.  The language permits implicitly converting a single
value to an interface type.  It does not permit implicitly converting
a slice of some type to a slice of some interface type.  See the FAQ
entry https://go.dev/doc/faq#convert_slice_of_interface .

Ian

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcUt4%3DpNX-ruDG9h2cCiFPG8U0uGZBAM%3DfdVt-Lo1yj%3DJA%40mail.gmail.com.

Reply via email to