One handy trick that I've found a lot of people don't know:
There's often the problem when working in IRB that you want to run a command that will produce a huge amount of output. For example, you might be reading a large file and assigning its value to a variable:
s = File.read("largefile.txt")
This can take a long time, as you wait for Ruby to print the entire contents to the terminal. However, this can be avoided by using a semicolon and another statement:
s = File.read("largefile.txt"); 0
Now the only thing printed out to the terminal will be 0, but s will still get the contents of largefile.txt.
This confused the hell out of me when I came from MatLab to Ruby. I thought the semicolon was working like in MatLab to just suppress output. It wasn't... Many bugs ensued!
Having now watched the video, if someone had told me that '_' in irb was equivalent to 'ans' in MatLab, I would have been very happy.
Ohh, you're giving me ideas now. How great would it be to have a whole panoply of "[language a] for [language b] developers" videos or articles ;-) I know of a few but still..
Pry is in exactly the same basket as awesome_print in terms of awesomeness, IMHO. It just did make my genuinely random selection for this video but will definitely be in the finished item :-)
Another neat IRB trick is to put a useful expression after the semicolon, like in your case s.length. This is especially useful on, say, the Rails console.
Also keep in mind that Ruby can evaluate lots of different expressions, so if say you calculated a number "n" and expect that there are "n" records that meet a given query, you can go:
There's often the problem when working in IRB that you want to run a command that will produce a huge amount of output. For example, you might be reading a large file and assigning its value to a variable:
This can take a long time, as you wait for Ruby to print the entire contents to the terminal. However, this can be avoided by using a semicolon and another statement: Now the only thing printed out to the terminal will be 0, but s will still get the contents of largefile.txt.