Safe navigation operator

Jeyvison Nascimento jeynoronha at
Wed Jan 16 19:29:29 UTC 2019

Hi Remi,

it's true that we shouldn't return null in our methods but, in practical, I
don't see it happening a lot. We can handle it and make our code behave
nicely when we are developing something but we can't do the same when we
are working with legacy/third-party code. When working with this kind of
code, we still have to do all the null checking process (what can be a lot
of if's) or use Optional.<Anything>.

"null" can also be something meaningful to the app creator and, although it
might not be best practice, we would be enforcing the perspective that
"null" shouldn't be propagated.

Shouldn't it be something that we should consider again?

Em qua, 16 de jan de 2019 às 14:02, Remi Forax <forax at> escreveu:

> 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 (or flatMap()) is the equivalent of the nullsafe
> navigation syntax.
> regards,
> Rémi
> ----- Mail original -----
> > De: "Jeyvison Nascimento" <jeynoronha at>
> > À: "amber-dev" <amber-dev at>
> > 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

Jeyvison Nascimento

More information about the amber-dev mailing list