3 ms·
I'd like Java to add support for the null coalescing operator `?.` and associated `!.` and `?:`. -- I find this easier to use and read than using Optional or nu
by rhdunn 2y ago
I'd like Java to add support for the null coalescing operator `?.` and associated `!.` and `?:`. -- I find this easier to use and read than using Optional or null check code.
I find heavy use of Optionals for nullable values can quickly overwhelm the codebase and make it hard to read the control flow. Especially when interacting with other parts of the codebase.
E.g.
var baz = foo?.bar?.baz ?: return false;
vs something like:
var baz = foo.map(f => f.bar).map(b => b.baz).getOrElse(null);
or using `then`.