Y
Hacker News
new
|
ask
|
show
|
jobs
by
bazoom42
687 days ago
Like an enum, a union have a closed set of elements so it can be statically checked all cases are handled.
With an interface, someone could add a new implementation, causing codee to fail at runtime.