Making Decisions

if / else

Programs constantly choose between paths. if runs a block of code only when a condition β€” an expression whose type is Bool β€” is true. else provides the block to run when it isn't.

Conditions usually come from comparison operators, each producing a Bool:

  • == equal (two equals signs! a single = assigns)
  • != not equal
  • < > less / greater than
  • <= >= less / greater than or equal