Safe navigation operator
Remi Forax
forax at univ-mlv.fr
Wed Jan 16 17:02:36 UTC 2019
Hi Jeyvison,
The nullsafe navigation has been proposed as part of the project Coin (for Java 7).
As far as i remember, it has been rejected because it allows to seamlessly propagate null in the code which is not the good solution, methods should you never return null, so you should not have to propagate it.
Since then, Java 8 has introduced Optional which force the user of a method that return Optional to take care of the fact that the method can return no result.
The method Optional.map() (or flatMap()) is the equivalent of the nullsafe navigation syntax.
regards,
Rémi
----- Mail original -----
> De: "Jeyvison Nascimento" <jeynoronha at gmail.com>
> À: "amber-dev" <amber-dev at openjdk.java.net>
> Envoyé: Mercredi 16 Janvier 2019 16:13:02
> Objet: Safe navigation operator
> Hi Folks :)
>
> Not sure if this is the best mail list to start it but I'd like to start a
> discussion about safe navigation operator (i.e "?." in Kotlin) in java.
>
> Not sure if this was already talked about but if it wasn't I think it's
> something worth to investigate and explore.
>
> What do you people think about it?
>
> --
> Jeyvison Nascimento
More information about the amber-dev
mailing list