Assignment
Assignment
In Ruby, assignment uses the =
(equals sign) character. This example assigns the number five to the local variable v
:
v = 5
Assignment creates a local variable if the variable was not previously referenced.
Local Variable Names
A local variable name must start with a lowercase US-ASCII letter or a character with the eight bit set. Typically local variables are US-ASCII compatible since the keys to type them exist on all keyboards.
(Ruby programs must be written in a US-ASCII-compatible character set. In such character sets if the eight bit is set it indicates an extended character. Ruby allows local variables to contain such characters.)
A local variable name may contain letters, numbers, an _
(underscore or low line) or a character with the eighth bit set.