Lesson 2.5: Truthiness Flashcards
if true puts 'hi' else puts 'goodbye' end
You can use the two boolean objects in conditionals.
Example 1 - The question will always output ‘hi’.
You can use the two boolean objects in conditionals.
Example 1 - The below will always output ‘goodbye’.
if false puts 'hi' else puts 'goodbye' end
code expression
An expression is a chunk of Ruby code that the Ruby interpreter can evaluate to produce a value.
short-circuiting
Short-circuiting is a programming concept by which the compiler skips the execution or evaluation of some sub-expressions in a logical expression. The compiler stops evaluating the further sub-expressions as soon as the value of the expression is determined.
https://www.geeksforgeeks.org/short-circuit-evaluation-in-programming/
Truthiness
In fact, Ruby is a very liberal language and considers everything to be truthy other than false and nil.