1
I have a type attribute
BigDecimal
x.I need to call a method
exampleMethod()
.I would like to pass the parameter
true
orfalse
depending on whether x is null or not, as in the example below:val x: BigDecimal? = null if (x != null) exampleMethod(true) else exampleMethod(false)
There is another more optimized way to verify that it is null and returns true
or false
so I don’t need to use the if
? As in the Java example below:
exampleMethod(Objects.nonNull(x))
Did the answer resolve what was in doubt? Do you need something else to be improved? Do you think it is possible to accept it now?
– Maniero