A value can be most anything, like a name ("Jeremy"
), a whole number (5000
), or a decimal number (3.14
). We use values in conjunction with commands to give Ruby instructions on what to do. We'll talk more about commands in a bit.
Every value can be described by a type. There are lots of types in Ruby, and we are going to talk about three of them today: String
, Fixnum
, and Float
.
A String
is any sequence of letters and/or numbers enclosed in either single ('
) or double ("
) quotes. "Elephant Hotdog"
is a String
, and so is '42'
. Most of the time, you can use either single or double quotes to create a string value.
A Fixnum
is a whole number expressed without a decimal. There's a couple ways to create fixnum values, but the most common is to type out the number. 1
is a Fixnum
, and so is 23
and -4500
.
A Float
is a number expressed with a decimal value. For example, float values can be expressed by typing a number with a decimal like 3.14
, 0.05
, and 1000.2387
.
There are important distinctions between doing math in Ruby with fixnum and float values, but we will talk about those differences later.