4 ms·
Reminds me of a joke in a John Meaney novel, a physicist discovers faster-than-light travel through a dimension with unusual properties, gaining inspiration fro
by rm445 3y ago
Reminds me of a joke in a John Meaney novel, a physicist discovers faster-than-light travel through a dimension with unusual properties, gaining inspiration from Java's booleans having three states (true, false and NullPointerException).
- Phrodo_00 3y agoHate to point it out, but java booleans can only be true or false. Booleans (capital B) can be true, false or null.
- dfox 3y agoMethod that is declared as only ever returning bool can also raise any exception that is an instance of java.lang.RuntimeException (which includes NullPointerException) this somewhat bizzare design which combines unchecked and checked exceptions is a source of major discussions since at least late 90's and has much to do with the current concept of null-safety.
- hedora 3y agoYeah, but using a raw boolean or Boolean is not considered good practice. They’re up to at least four states now: null, None, Some(TRUE) and Some(FALSE) Of course, if you want more than that, you can have unboundedly many by invoking new Boolean(), which guarantees its return value is unique according to ==