Ruby Literals
Ruby has special syntax for scalar values that are booleans, numbers, lambdas, ranges, regular expressions, strings, symbols, and array and hash collections. Although all types in Ruby are implemented as classes, these types have special syntax for creating literal values of them. Lambda literals will be covered in Proc Objects; we’re going to discuss the rest here.
Boolean Literals
Ruby provides the literal values true and false. The true value is the instance of the singleton class TrueClass and represents a true value in logical expressions. The false value is the instance of the singleton class FalseClass and represents a false value in logical expressions. The literal value nil is the only instance of the singleton NilClass ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access