--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/26c4bcfc-f67b-4638-a812-dce9c8c9b275%40googlegroups.com.
Go doesn't do any implicit type conversions, and it's quite consistent about that. The only things which are type "converted" are untyped constants.
I would love for this to work too, by the way, since I often come up with something like:
var a []interface{}
var b []SomethingConcrete
I would love to be able to assign a to b without having to loop, but it won't work because their sizes are completely different, so the compiler can't emit a single conversion of this type, since one structure isn't safely coercible to the other type. This would be along the lines of reinterpret_cast<> in c++, which can corrupt memory.
On Mon, Apr 13, 2020 at 6:56 PM Glen Huang <hey...@gmail.com> wrote:
Given--type Data []bytes := [][]byte{{1},{2}}I wonder why this conversion isn't allowed?[]Data(s)Seems pretty straightforward. Maybe I miss some edge cases where things won't square?
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 golan...@googlegroups.com.