Conditional structures: Difference between revisions

Content added Content deleted
m (copy edit - wiki link to wikipedia)
Line 946: Line 946:
deusEx();
deusEx();
}</lang>
}</lang>
Java also supports [http://en.wikipedia.org/wiki/Short-circuit_evaluation short-circuit evaluation]. So in a conditional like this:
Java also supports [[wp:Short-circuit_evaluation|short-circuit evaluation]]. So in a conditional like this:
<lang java>if(obj != null && obj.foo()){
<lang java>if(obj != null && obj.foo()){
aMethod();
aMethod();
Line 1,906: Line 1,906:
results=dispatcher[x]()
results=dispatcher[x]()


This can be particularly handy when using [http://en.wikipedia.org/wiki/Currying currying] techniques, or when lambda expressions or meta-function generators (factories) can be used in place of normal named functions.
This can be particularly handy when using [[wp:Currying|currying]] techniques, or when lambda expressions or meta-function generators (factories) can be used in place of normal named functions.


In general a dispatch table or class/object abstraction (using dynamic method over-rides) is considered preferable to chains of ''if ... elif ... elif ...'' in Python programming.
In general a dispatch table or class/object abstraction (using dynamic method over-rides) is considered preferable to chains of ''if ... elif ... elif ...'' in Python programming.