January 2024
Intermediate to advanced
718 pages
20h 15m
English
Ruby has several different mechanisms for the conditional execution of code; they should feel similar to other programming languages, but many have some neat twists. Before we get into them, we need to spend a short time looking at boolean expressions.
Ruby has a simple definition of truth. Any value that isn’t nil or the constant false is true—"cat", 99, 0, and :a_song—are all considered true. An empty string "", an empty array [], and an empty hash {} are all true in Ruby. (You’ll sometimes see Rubyists refer to the set of all false values as “falsey” and the set of all true values as “truthy”.)
In this book, when we want to talk about a general true or false value, we use regular Roman type: true ...
Read now
Unlock full access