I work with some business logic written in Kotlin. I've got such a case in my method - I check a value for null, and if it IS null - I want to return null, else do some logic. My version looks like:
fun calculateFoo(parameter: SomeObject?): ReturnObject? =
if (parameter == null) null
else performCalculation(parameter)
Literally "If value is null then return itself else process it". Normally, we do something if value is NOT null, like elvis operator, but here is "reversed" logic. Is there a better solution for this?