Re:Optional If Expressions
by marginalia_nu on Saturday April 15, 2023 @07:40AM
(#35579700)
I don't think amending the type system (or using the existing type system) would make sense for Java.
I think either a null-delegating operator (like C#'s foo.?bar ); or a variable modifier (a bit like 'final') that doesn't permit nulls would make far more sense in the context of the language at large. In fact, the approach is commonly enforced through annotations and static analysis. Built-in support for the construct would be very beneficial.
Re:Optional If Expressions
by valenterry on Saturday April 15, 2023 @04:16PM
(#35584140)
Yeah, I agree.
And syntactically, it's not a pleasure to use, but that's more a fault of Java being so verbose and limited in terms of the typesystem, not a fault of the Optional type.