โ Ruby Programming learning pathRuby Programming ยท Module 3 of 10
Control flow
if, unless, case and loops steer a Ruby program.
๐ Key ideas
- if / elsif / else / end handles choices.
- unless runs code when a condition is false.
- Modifiers read naturally: puts "Pass" if marks >= 40.
- case / when matches values or ranges like 90..100.
- 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