Literals
Literals
Literals create objects you can use in your program. Literals include:
-
Booleans and nil
-
Numbers
-
Strings
-
Symbols
-
Arrays
-
Hashes
-
Ranges
-
Regular Expressions
-
Procs
Booleans and nil
nil
and false
are both false values. nil
is sometimes used to indicate “no value” or “unknown” but evaluates to false
in conditional expressions.
true
is a true value. All objects except nil
and false
evaluate to a true value in conditional expressions.
(There are also the constants TRUE
, FALSE
and NIL
, but the lowercase literal forms are preferred.)
Numbers
You can write integers of