JumpStart Live (JSL)
Boolean zen is a phrase used to describe if code using boolean values is written in the most concise way possible. Boolean zen is considered good programming style.
- You should never compare to true or false in an if statement, while loop, or until loop
# not boolean zen
if width > 0 && width < 100
puts true
else
puts false
end
# boolean zen
puts width > 0 && width < 100
# not boolean zen
correct = false
until correct == true
# statement(s)
end
# boolean zen
correct = false
until correct
# statement(s)
end
# not boolean zen
not_correct = true
while not_correct == true
# statement(s)
end
# boolean zen
not_correct = true
while not_correct
# statement(s)
end
- Ada Boolean Zen Video (2:55)