Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
campbel
on Jan 5, 2024
|
parent
|
context
|
favorite
| on:
Go: What we got right, what we got wrong
Couldn't we do an optional type with the type system as is rather than embedding in the language?
type Optional[V any] struct { IsSet bool Value V }
kaba0
on Jan 5, 2024
|
next
[–]
The type system would store it at compile time, while your type would only have it at runtime.
ncruces
on Jan 5, 2024
|
prev
[–]
How does that prevent an unset Value from being used?
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search:
type Optional[V any] struct { IsSet bool Value V }