Foo foo = bar.getFoo();
if (foo != null) {
//
}
This is something that EnScript gets right: pretty much every EnScript expression can be evaluated as a boolean value, without having to use boolean operators.
References
Foo foo = bar.getFoo();
if (foo) { // true if foo is non-null
//
}
Integers
int i = 0;
if (i) { // true if i is non-zero
//
}
Strings
String s = "";
if (s) { // true if s is not empty
//
}
Once you get used to this [COMPLETELY OBVIOUS] shorthand, it's hard going back to a language that thinks there's something magical about boolean expressions.
No comments:
Post a Comment