Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> it doesn't play well if you're using Literals instead of Enums as the discriminator type

The original example code with Enums doesn't type-check either, and for the same reason:

If the type checker allowed that, someone could take an object of type Foo, assign it to a variable of type _FrobulatedBase, then use that variable to modify the kind field to 'bar' and now you have an illegal Foo with kind 'bar'.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: