Interactive Ruby
This lesson goes over interactive ruby (irb): why and how we use it
Topics
Interactive Ruby
Scenario
- You’re working on a coding problem 🧑💻.
- You need to test and experiment with small snippets of Ruby code quickly and interactively test an idea.
- Luckily, you have the IRB shell 🪄✨.
- In the IRB shell, you can try out lines of Ruby code and see the results immediately, without the need for writing and running a whole program.
- It’s like having a virtual playground where you can experiment and explore the capabilities of Ruby in real-time ⚙️🔬.
- With each session in the IRB shell, your skills grow stronger, and you’ll become more confident in your ability to write robust and efficient Ruby code 💪💎.
Shell
- open a terminal
- In a terminal you can enter
ruby --version
or ruby -v
to check version
- Make sure you are using the correct version in Ruby Docs
- type
irb
and hit enter
- You are now in the
irb
shell
- Play around with ruby.
- Create a variable.
name = "ian"
- Print to I/O.
puts name
- etc.
- Type
exit
and hit enter to exit irb shell
- Yay! 🎉 You’ve done your first irb session
Resources
Ruby Docs
Ruby Docs
Unix
Commands Cheatsheet
Next Up
Workspace