Concept Flow - Boolean values (true, false, nil)
Start
Evaluate expression
Is value true?
Yes No
Use true
Use false
Use nil
End
This flow shows how Ruby evaluates values as true, false, or nil and how each is treated in conditions.
a = true b = false c = nil puts a puts b puts c
| Step | Action | Variable | Value | Output |
|---|---|---|---|---|
| 1 | Assign true to a | a | true | |
| 2 | Assign false to b | b | false | |
| 3 | Assign nil to c | c | nil | |
| 4 | Print a | a | true | true |
| 5 | Print b | b | false | false |
| 6 | Print c | c | nil |
| Variable | Start | After 1 | After 2 | After 3 | Final |
|---|---|---|---|---|---|
| a | undefined | true | true | true | true |
| b | undefined | undefined | false | false | false |
| c | undefined | undefined | undefined | nil | nil |
Boolean values in Ruby: - true and false are Boolean literals. - nil means 'no value' and acts like false in conditions. - Printing true or false shows 'true' or 'false'. - Printing nil shows an empty line. - Use these values in conditions to control flow.