Do you sometimes use the non-expression version of...
# codingconventions
f
Do you sometimes use the non-expression version of if/else for readability, even if it could be written as an expression?
g
what is non-expression version of if/else? Isn't it one version and it's always an expression?
f
I mean as a statement
like in Java
you know we could write
Copy code
if (x) {
    a = 1
} else {
    a = 2
}
in which case we don't use
if
as an expression. Or we're could write
a = if (x) 1 else 2
I'm wondering if people sometimes use the first variation just for readability
g
It's more like a common sense thing than coding convention for me. Also, IDE has some good suggestions when it's actually makes sense to lift it up as an expression.
m
f
Thank you