Creating Numbers
In order to work with any variable type, you first need to know how to create one. Unlike many other programming languages, Ruby does not require that you declare variables: indicate that a variable of a specific type exists. Instead, a variable in Ruby is often first referenced when it’s assigned a value. Doing so makes use of the assignment operator, which is a single equals sign. The basic syntax is
identifier = value
A variable’s identifier, which is to say its name, consists of letters, numbers, and underscores. Variable names cannot start with a number, and, most importantly, they are case sensitive. Variable names should not begin with a capital letter, as that naming scheme is reserved for constants (covered later in ...
Get Ruby: Visual Quickstart Guide 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.