Chapter 2: Installation and Setup
To use Ruby, we first have to install it on our computer. In this section, we’ll install the latest version of Ruby. If you’re on a Mac, it already comes with Ruby. However, it’s most likely an older version of Ruby.
Chapter 3: Your First Ruby Program
Now that we have installed Ruby on the computer, the next step is to write a simple program and run it.
Chapter 4: Variables
It’s time to dive into various interesting features of Ruby. We’ll start with the most basic concept in programming: variables.
Chapter 5: Comments
Sometimes, you want to add helpful notes and instructions to your code for others, even you. Trust me, when you come back to a piece of code you wrote six months ago, it’s often hard to figure out what it does.
Chapter 6: Operators
Ruby supports all the operators you learned in high-school Maths, and many more. In this section, we’ll learn about operators in Ruby.
Chapter 7: Strings
A string is simply a list of characters, for example ‘hello world’ and ‘abcd’. The characters don’t necessarily have to mean anything. In real programs, you may use strings to insert and display text on the web page. Open any website. Whatever text you see there, it’s all made up of strings.
Chapter 8: Symbols
Symbols are simply strings that are guaranteed to be unique. Instead of quotes, symbols are indicated by adding a colon :
character behind the word. For example, :gmail
is a symbol. If you create another :gmail
it will represent the same symbol you created earlier.
Chapter 9: Arrays
Arrays are ordered lists of values grouped under a common name.
Chapter 10: Hash
A Hash is similar to an Array, but stores a list of key-value pairs. In an array, each element has a positional index, but a Hash key can be anything, and the key has to be unique.
Chapter 11: Conditions
We’ve seen the comparison operators like <
, >
, <=
, >=
, ==
, ===
, !
, !=
, etc. These operators are typically used in control statements, like conditionals, loops, etc. Conditionals are the first control structure we’ll see.
Chapter 12: Loops
Loops are another super useful control structure that lets you repeat a piece of code for a certain number of times, or until a condition is met.
Chapter 13: Group Related Code with Functions
Functions are one of the most important concepts in programming. You can use functions to group together multiple instructions, multiple lines of code, and give them a name.