I\'m kinda waiting for a \'no\' answer on this question.
I was interested if you can save a variable at the same time when you checking it in an if-clause.
From the department "My Programming Language is Better Than Your Programming Language": In Groovy, you can use the "?." operator:
Bar bar = foo?.bar
if (bar != null) {
}
In Java, this is good pattern(*):
Bar bar = foo == null ? null : foo.getBar();
if (bar != null) {
}
*: Something you can save in your fingertips.