0
0
Rubyprogramming~15 mins

IRB for interactive exploration in Ruby - Mini Project: Build & Apply

Choose your learning style9 modes available
Exploring Ruby with IRB
📖 Scenario: You are learning Ruby and want to explore how to use IRB (Interactive Ruby Shell) to try out Ruby commands quickly. IRB lets you type Ruby code and see the results immediately, like a conversation with your computer.
🎯 Goal: Learn how to start IRB, create variables, perform simple calculations, and print results interactively.
📋 What You'll Learn
Start IRB in the terminal
Create a variable called greeting with the value "Hello, IRB!"
Create a variable called number with the value 10
Calculate the square of number and store it in square
Print the value of square
💡 Why This Matters
🌍 Real World
IRB is a tool Ruby developers use daily to quickly test ideas, debug code, and learn Ruby commands without writing full programs.
💼 Career
Knowing how to use IRB helps you become a more efficient Ruby programmer and is a valuable skill in software development jobs that use Ruby.
Progress0 / 4 steps
1
Start IRB and create a greeting variable
Open your terminal and start IRB by typing irb. Then create a variable called greeting and set it to the string "Hello, IRB!".
Ruby
Need a hint?

Type irb in your terminal to start. Then type greeting = "Hello, IRB!" and press Enter.

2
Create a number variable
In IRB, create a variable called number and set it to the integer 10.
Ruby
Need a hint?

Type number = 10 and press Enter.

3
Calculate the square of number
In IRB, create a variable called square and set it to the value of number multiplied by itself.
Ruby
Need a hint?

Type square = number * number and press Enter.

4
Print the square value
In IRB, print the value of square by typing puts square.
Ruby
Need a hint?

Type puts square and press Enter. You should see 100 printed.