What is the purpose of question mark(?) after a variable in Groovy

?. is a null safe operator which is used to avoid unexpected NPE.

if ( a?.b ) { .. }

is same as

if ( a != null && a.b ) { .. }

But in this case is() is already null safe, so you would not need it

other.is( this )

should be good.

Leave a Comment