Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
bradfitz
on July 31, 2013
|
parent
|
context
|
favorite
| on:
Twelve Go Best Practices
Just sending "true" as a signal is a convention, but some people prefer something like
http://play.golang.org/p/oXapo7R4RX
frou_dh
on July 31, 2013
|
next
[–]
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
on July 31, 2013
|
parent
|
next
[–]
Many languages call it unit or ().
frou_dh
on July 31, 2013
|
root
|
parent
|
next
[–]
Hah, I was just about to edit my comment to mention unit after doing some reading :)
exch
on Aug 1, 2013
|
prev
[–]
I'll add that the reason for using `struct{}` over `bool`, is that an empty struct occupies 0 bytes, whereas a boolean occupies 1.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: