mercredi 18 avril 2018

How can I replace if true in java 8 without braces?

I do have some condition in code, for example:

if (isTrue) { ... }

and I'm wondering can I replace this with some java 8 stuff, something like this (just to avoid ugly braces):

Optional.of(isTrue).ifPresent((a) -> callSomeFunc(a));

Optionals don't have ".ifTrue" so does java 8 have something similar?

Aucun commentaire:

Enregistrer un commentaire