Michael
02/07/2019, 8:11 PM{ .....some lines.... if (condition) { null } ..... final value }
Dominaezzz
02/07/2019, 8:12 PMif (condition) { null } else { ..... final value }
I think.karelpeeters
02/07/2019, 8:12 PMreturn@foo null
.Michael
02/07/2019, 8:23 PMgroostav
02/07/2019, 9:06 PMif(condition) { null } otherValue
as failing to compile with a compiler error something along the lines of
, usingif(...) { null }
without a parent statement is illegal in this context. Either assign the expression to a value, return it, or simply invoke the condition.null
if(condition)
is a problem because condition
may have side effects, but if(ANY_EXPR) { CONSTANT_EXPR }
is odd even if ANY_EXPR
has a side effect when CONSTANT_EXPR
is unused --and of course, in the overwhelming majority of cercomstances, people use ANY_EXPR
as being ref-transparent, so the whole thing is almost certainly not what the programmer wanted.