Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
JLS Myths - If-then-else statement -
1. JLS myths
~ if-then-else statement ~
HASUNUMA Kenji
k.hasunuma@coppermine.jp
GlassFish Users Group Japan
2. if-else statement
if ( someObject.eval() )
if ( otherObject.eval() )
func1();
else
func2();
assume that someObject.eval() is false.
which is run, func1 or func2?
3. if-else statement
if ( someObject.eval() )
if ( otherObject.eval() )
func1();
else
func2();
assume that someObject.eval() is false.
Neither func1 nor func2 is run.
4. if-else statement
if ( someObject.eval() )
if ( otherObject.eval() )
func1();
else
func2();
It's if-else's short-circuit.
Don't be misled by source code format!
5. From JLS (Java SE 8)
IfThenStatement:
if ( Expression ) Statement
IfThenElseStatement:
if ( Expression ) StatementNoShortIf
else Statement
IfThenElseStatementNoShortIf:
if ( Expression ) StatementNoShortIf
else StatementNoShortIf
8. if-else statement (fixed)
if ( someObject.eval() ) {
if ( otherObject.eval() )
func1();
} else
func2();
assume that someObject.eval() is false.
which is run, func1 or func2?
9. if-else statement (fixed)
if ( someObject.eval() ) {
if ( otherObject.eval() )
func1();
} else
func2();
func2 is run!
because it use block as statement in outer
if statement
10. JLS myths
~ If-then-else statement ~
HASUNUMA Kenji
k.hasunuma@coppermine.jp
GlassFish Users Group Japan