On 12.01.21 22:37, Jack wrote:
I was looking for a way to avoid null checks everywhere. I was checking
the Null object pattern, or use something like enforce pattern, or even
if I could make a new operator and implement something like C#'s .?
operator, that Java was going to have one but they refused[1] (doesn't
behave exactly as C#'s actually), Kotlin also got something in this area[2]
What some D ways to avoid those checks?
[1]:
https://mail.openjdk.java.net/pipermail/coin-dev/2009-March/000047.html
[2]: https://kotlinlang.org/docs/reference/null-safety.html#safe-calls
Did you have a look at https://code.dlang.org/packages/optional?
Especially https://aliak00.github.io/optional/optional/oc/oc.html might
go in the right direction.
Kind regards,
Christian