January 2024
Intermediate to advanced
718 pages
20h 15m
English
Ruby variables and constants hold references to objects. Variables themselves don’t have an intrinsic type. Instead, the type of a variable is defined solely by the messages to which the object referenced by the variable responds. (When we say that a variable is not typed, we mean that any given variable can at different times hold references to objects of different types.)
A Ruby constant is also a reference to an object. Constants are created when they are first assigned to (normally in a class or module definition). Ruby, unlike other less flexible languages, lets you alter the value of a constant, although this will generate a warning message, which gets sent to $stderr:
| | MY_CONST = 1 |
| | puts "First MY_CONST ... |
Read now
Unlock full access