Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
bradfitz
· 13y ago · 0 comments
Just sending "true" as a signal is a convention, but some people prefer something like
http://play.golang.org/p/oXapo7R4RX
Comments
[–]
frou_dh
13y ago
Cool, I like that. In some ways, it would be nice if there were a friendly alias for struct{} as part of the language, but I suppose it's hard to come up with a good general name for that.
[–]
lmm
13y ago
Many languages call it unit or ().
[–]
frou_dh
13y ago
Hah, I was just about to edit my comment to mention unit after doing some reading :)
[–]
exch
13y ago
I'll add that the reason for using `struct{}` over `bool`, is that an empty struct occupies 0 bytes, whereas a boolean occupies 1.