Skip to content

Instantly share code, notes, and snippets.

@ajtran303
Last active February 21, 2020 03:33
Show Gist options
  • Save ajtran303/9959fc8c6d9d64b2cf13fab1cd734e66 to your computer and use it in GitHub Desktop.
Save ajtran303/9959fc8c6d9d64b2cf13fab1cd734e66 to your computer and use it in GitHub Desktop.

beginners_guide_to_data_types.md

by AJ Tran

1. String data

Strings are a fancy way of saying data made of text characters. They are surrounded by double or single quotations.

string = "Hello, World!"

2. Integer and Float data

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.

3. Boolean data

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."

4. Array data

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]

5. Hash data

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" }

Look at this raven:

image of a raven

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment