Data Types in Ruby
Explore the fundamentals of data types in Ruby, including strings, integers, and objects. Learn how to identify an object's type using the .class method and understand the importance of Ruby's object-oriented structure. This lesson helps you grasp how Ruby treats data as objects with methods, empowering you to better understand and manipulate data in your programs.
We'll cover the following...
Data types
In the previous chapters, we figured out how to join two strings with "+". Also, we know now that we can multiply a string by a number. While experimenting, we found that there are at least two types of data: strings and numbers, also known as integers. We also learned that a number itself, written in quotation marks, is a string. Let’s see how Ruby understands what a number and what a string is:
The documentation says that everything is an object in Ruby. So, the result of any operation is an object. Every object implements a method called a class. The expression “implements a ...