โ† Ruby Programming learning path
Ruby Programming ยท Module 3 of 10

Control flow

if, unless, case and loops steer a Ruby program.

๐Ÿ“– Key ideas

  1. if / elsif / else / end handles choices.
  2. unless runs code when a condition is false.
  3. Modifiers read naturally: puts "Pass" if marks >= 40.
  4. case / when matches values or ranges like 90..100.
  5. Loops: while, until, and each over collections.
๐Ÿ’ก Real-life example: Like a school rule book: "unless it rains, assembly is outside" and "case grade when A ... when B ...".
unlessRuns when the condition is false
caseMulti-way branch on a value
RangeA span of values like 1..10
Modifier ifCondition written after the statement