Ternary operator in if-statement?
Posted
by Pindatjuh
on Stack Overflow
See other posts from Stack Overflow
or by Pindatjuh
Published on 2010-05-12T23:29:16Z
Indexed on
2010/05/12
23:34 UTC
Read the original article
Hit count: 247
I've written the following if
-statement in Java:
if(methodName.equals("set" + this.name) ||
isBoolean() ? methodName.equals("is" + this.name) :
methodName.equals("get" + this.name)) {
...
}
Is this a good practice to write such expressions in if
, to separate state from condition? And can this expression be simplified?
© Stack Overflow or respective owner