Hacker News new | ask | show | jobs
by nicoty 635 days ago
I'm not familiar with Java. Does it have no notion of structural types at all? If it does, maybe you could wrap those fields in `Car` with `Maybe`/`Option` (I’m not sure what the equivalent is in Java) so you get something like `Car(Maybe Make, Maybe Model, Maybe Year, Maybe Colour)`?
2 comments

Records are structural types. Null restricted types are in draft: https://openjdk.org/jeps/8303099
Records in Java are nominal. In fact, it is syntax sugar for a class.
yes and it is called Optional (rather than Maybe)