Professional Documents
Culture Documents
Lead The Flow: Section 4
Lead The Flow: Section 4
Condition Construction
• Equality condition is expressed with == (while a single = means assignment)
• And the opposite (inequality) is tested with != operator.
• Condition precedence:
o “And” beats “Or” (same logic as “multiplication beats addition”)
• Condition construction operators:
o && means “And”
o || means “Or”
o ! means “Not”
The Switch
• Condition with multiple outcomes requires a switch:
• Syntax:
o switch(<variable>) { case <first possible value>: … break; case <second..>: … break; …
; default: … break; }
Variable Scopes
• Using a variable outside of the scope where it was defined will issue a compiler error.
• Defining variables outside of any scope turns them into “global” variables accessible from
anywhere.
Cheers!
Shmuel.