Strings are a fancy way of saying data made of text characters. They are surrounded by double or single quotations.
string = "Hello, World!"
There are two numerical data types in Ruby.
- Integer data is any whole number
int = 10
. - Float data are any number with decimals
float = 100.2
.
Boolean data is just a fancy way of deciding if something is true
or false
. These boolean values are determined by logical expressions using boolean operators like "and" and/or "or."
An array is a collection of things. It's basically like a list. It can have anything in it. Can you tell what data types are in the following array?
array = ["a", 2, nil, false, true, 3.3]
A hash is a collection of objects grouped into key-value pairs. It's like another type of list. Phone books are a good example of hashes. Every listing in the white pages has a person as the key and their phone number as the value.
phone_hash = { "AJ": "303", "EG": "978" }