Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialWayne Greenwood
15,907 PointsCan I ask what real life uses would you use an irb when you already have a code editor open?
Can I ask what real life uses would you use an irb when you already have a code editor open? As with Python you can use the terminal to run shorthand code but it can be quite distracting as you are learning shorthand and syntax coding for the same language.
4 Answers
John Steer-Fowler
Courses Plus Student 11,734 PointsHi Wayne,
The IRB is a really useful tool for ruby programmers.
I personally use it as a kind of playground to experiment with code quickly and get instant results rather than have to run a script each time.
The most useful use in my opinion, is if you have built a large program in your code editor, and you want to test some code before you put it into your program, you can, without having to run your whole program to see if the code works
I hope this gives a little more understanding. When you pick up the ruby language, you will start to see the benefits more.
jaisonbrooks
4,608 PointsIRB is awesome, its the best testing ground for Ruby related code. If you're doing Ruby on Rails development, you can get the same equivalent to IRB via a Rails c (rails console). This helps you check Class methods, paste a method you wrote and want to test out, or directly play around with your Active Record objects and soooo much more.
I use IRB daily, anytime im writing a new method, i'll paste it into IRB and play around with it, making sure the code does what it's supposed to do. Then of course, i'll write a test to make sure it does it every time going forward.
Wayne Greenwood
15,907 PointsHi Jaison
Yeh I use IntelliJ Idea Ultimate IDE and it has a built in terminal that allows me to use the IRB at the bottom of my IDE. I can now see how it is useful in development I wasn't sure if it was a tool that was widely used but I think I shall be using it from now on. Cheers for the insight.
Wayne Greenwood
15,907 PointsAhh I see..
Cheers John
Kevin Korte
28,149 PointsJohn is correct, it is a great tool to quickly isolate parts of your code. You can quickly see what a piece of code or logic is doing, return, or erroring. I use it all the time to try things our, or manipulate something in basically real time.
Wayne Greenwood
15,907 PointsWayne Greenwood
15,907 PointsHi John
Thank you for the Input much appreciated:-) So essentially its used as a testing ground for code you don't want to include into a bigger program incase its breaks it?
John Steer-Fowler
Courses Plus Student 11,734 PointsJohn Steer-Fowler
Courses Plus Student 11,734 PointsHi Wayne,
Not necessarily incase it breaks it, but it's just a quick and easy place to test ruby code before using it in a long program.
Remember that a lot of programmers will have very large programs with thousands of lines of code. You don't want to have to run your whole program/game/website, just to test a coding concept
This is what makes IRB great