Main Content

Some Ruby programming examples from our course

Archive - Originally posted on "The Horse's Mouth" - 2008-03-21 18:22:20 - Graham Ellis

I was giving a Public Ruby Course to a small group at the end of last week ... and having a small group gave me the opportunity to write some demonstrations in front of them. I have now tidied these up and have pleasure in presenting to more Ruby demonstrations:

Ruby's BEGIN block

The compact method - strips out nil members from an array

Writing comparator methods such as "larger" and "smaller" in Ruby

Using a hash to provide a table of counters

Calling another process via a pipe in Ruby

Definition and use of a class in Ruby

Definition and the redefinition of the same function in Ruby