Built-In Data Types
As mentioned before, Ruby comes with lots of things already baked in, and provides you with tons of tools to use and hit the road running.
We’ll look at some of the most common data types in Ruby. Data types are types of “things” that are mainly used to represent data, such as numbers, text, and other values.
This is basically the “stuff” that you, as a Ruby programmers will work with, when we work with actual data, that is interesting to you, or your users in one way or the other.
We will discusss the following data types:
- Strings (texts)
- True, False, and Nil
These “kinds of things” (objects) cover like 98% of all built-in data types that you’ll be using on a day to day basis, i.e. these are being used all over the place. There are more data types, but those are rather exotic, and used much less often.
Numbers and Strings (which is just a strange name for “texts”) are some of the most basic “things” that you deal with in Ruby on a regular basis. The are also just enough lego bricks for us to dive into more interesting topics, such as how objects, classes, and methods relate to each other, and how you can create your own ones.
Before we do so we will also briefly mention the “things”
nil, just because these are things that we’ll come across along the way
Symbols also are very commonly used, but quite an odd concept. You normally wouldn’t need to understand Symbols in order to write your own code. We’ll still cover them briefly, and use them once in a while, just in case you find them elsewhere.
Arrays and Hashes are “things” (objects) that are used to store other things, and they’re super useful, and widely used.