-
Strings. Strings are some of the easiest data types. The only thing you need to do to indicate something is a string data type in Ruby is put it between quotes, either double (" ") or single quotes (' ').
-
Integers. Or numbers, these are indicated in Ruby by just typing the number (not spelled out).
-
Arrays. Arrays are nice, they allow you to tell Ruby that what follows is a list of elements I want to possibly manipulate later. I'll give two different examples of arrays;
- Numbered arrays: [1, 2, 3, 4]
- String arrays: ["George", "Travis", "Michael"]
- Hashes. Hashes are a bit more complicated, but the gist of hashes is; it's a list of items (called keys) with a corresponding value (usually number, but can be a string). An example of that would be someones favorite foods with their respective rating. Here's what that would look like;
"cookies" => 8,
"steak" => 9,
"peanut_butter" => 7
What I wrote above, in code, was: foods = Hash.new { key, value}
.