is this code really idiomatic (it is suggested by ...
# announcements
d
is this code really idiomatic (it is suggested by IDE plugin):
Copy code
fun hello() {
  someActionOrFunWhichTriggersNull ?: return
  statement1
  statement2
}
To me that
?: return
smells like using
? :
to perform side-effects in java:
Copy code
(i < 2) ? launchRockets() : goSafePath();
Which is not the right thing to do,
cond ? this : that
should be used as
int value = cond ? this : that
, in expressions. I would expect that elivs-operator (
?:
) in Kotlin is an "expression" operator too:
val v = getMaybeNull() ?: defaultValue
. Am I wrong?