Y
Hacker News
new
|
ask
|
show
|
jobs
by
sacado2
3710 days ago
Sum types don't fit well with zero values. What is the zero value of an `(int|string)` union type ?
1 comments
aninhumer
3709 days ago
Well I don't think zero values are a very good idea to start with (if you want a default value, make it explicit), but if one insists on having them, they can just use the first case. So for your example it would be int 0.
link