Browsing archives for 'General'

What is The Ruby Way?

General 3 October 2009 | 2 Comments

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

A Ruby Idiom: Defining Methods Based on Conditions at Runtime

General 5 October 2009 | 0 Comments

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 [...]

Basic Ruby Idioms: Checking For An Empty String

Data, General 4 October 2009 | 0 Comments

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? [...]

Kernel.abort: Quit and Print an Error to STDERR

General 4 October 2009 | 0 Comments

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 [...]