On Wednesday, 29 April 2020 01:33:55 UTC+1, Shishir Verma wrote:
>
> I think it is kind of intuitive that empty struct takes 0 bytes
>

To me it wasn't intuitive, but that's because my brain instinctively read 
it as "interface {}" and not "struct {}".

It's clear that a struct{} must occupy zero bytes.  It's not clear that 
such a construct is even legal, but it clearly is.  You can define a 
variable that takes zero bytes :-)  You can also define a zero-sized array, 
which achieves the same thing.
https://play.golang.org/p/16QuEbLj_89

Thanks for the trick!

-- 
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/d06c536a-8b4c-47a2-a40f-d145e6ef8218%40googlegroups.com.

Reply via email to