Zoonk icon

When we're creating a variable in Ruby, we're also assigning a data type to it. For example, when we write something like this:

car = "Tesla"

We're actually telling our program to create a variable whose value is a . But is just one data type available.

Programming languages can handle types in different ways. Some of them, such as Java and C are . That means you have to tell your program the variable type when you're declaring it.

Ruby, however, is . That means you don't need to tell your program what type your variable has. When you do it will automatically figure out you're creating a variable. If later on, you decide to change the type, you can do it by reassigning that variable. For example, if you do it , the same variable will be a now.

In Ruby, you can have the following types:

  • String (text)
  • Number
  • True
  • False
  • Nil
  • Symbol
  • Array
  • Hash

We'll cover those data types in the following chapters.