2. Ruby Data Types and Operations

Overview

By the end of this chapter, you will be able to perform operations on arrays and hashes; use Ruby methods on arrays and hashes; create your own Ruby method and write a Ruby program for rolling dice.

Introduction

In the previous chapter, we studied variables, constants, strings, and various data types. We performed various operations on strings and numbers. We were also introduced to the Interactive Ruby Shell (IRB), which makes coding in Ruby easier.

This chapter is dedicated to bringing you up to speed with arrays, hashes, and methods in Ruby. You could say that these are among the most fundamental topics. We will take a closer look at the different ways of creating arrays and hashes, as there ...

Get The Ruby Workshop now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.