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 ...
Get Programming Ruby 3.3 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.