For you specific use case: `if (str.isNullOrBlank(...
# announcements
k
For you specific use case:
if (str.isNullOrBlank()) "other" else str
s
expanding on this. You can directly assign the result of an if.
val someVariable = if (str.isNullOrBlank()) "other" else str
m
sure, yes i understand that can be done, but let’s say you want to perform some operation on the result. and chain it. you know, to make up for the lack of an optional type
to use a contrived example
foo.ifNullOrBlank(someOtherString).contains(…)
s
In the same way if can be assigned directly. You can wrap it in brackets and use the results
(if(str.isNullOrBlank()) "other" else str).contains("t")