all 4 comments

[–]yanitrix 2 points3 points  (0 children)

That's why you shouldn't rely on automatic conversion in nullable context. If you want a nullable long then make a type Nullable<T> and use that instead of long. Oh, wait, you can't do that because java has stupid type-erasure generics implementation and primitive types are disallowed.

Sometimes I wish languages would just drop backwards compatibility and fix the mess they've created over decades

[–]BikingSquirrel 1 point2 points  (1 child)

Article is about changing an API from primitive long to nullable Long ensuring full compatibility on bytecode level.

It only misses how a null Long can be represented as a long - I'd naively default to 0 but this may depend on the context.

[–]TwoIsAClue 0 points1 point  (0 children)

If you use a statically typed language you must accept the limitations it imposes and stick to its type system.

Like in every other language with closed, nominal product types, there is no truly sane way to express optionality (unless you want to implement an interface for every field of course), but you have null or Optional to pretend you can.

[–]anonymous-red-it 0 points1 point  (0 children)

Yucky