What is The Ruby Way?
Learn about the book The Ruby Way and how to buy it.

Learn about the book The Ruby Way and how to buy it.
On pages 36 and 37 of The Ruby Way (2nd Edition) Hal talks about “Coding at Runtime.” He specifically mentions how while ifdef directives can be used in C to change how things are defined depending on conditions set prior to the compile, you can just do the same at runtime in Ruby.
For example, let’s [...]
Page 15 of The Ruby Way (2nd edition) presents a basic Ruby idiom for checking whether a string is empty or not.
I believe there are three ways to do it (if you can think of any others, leave a comment!). Two reasonably obvious, but one that’s quite idiomatic (the one that The Ruby Way mentions):
str.empty? [...]
One of the great things about going through other people’s Ruby books is that you discover small tidbits about the language that you’d never noticed before. While skimming through The Ruby Way again to come up with ideas for this blog, I noticed a basic program on page 14 (2nd edition) that starts like so:
print [...]