Wednesday, November 30, 2005 - Posts

Take Ruby for a test-drive

If you haven’t been living in dark hole for the last six months, you’ve surely heard the buzz about dynamic languages, and Ruby in particular. Regular readers might recall me drawing some parallels between the new features in C# 3.0 and Ruby, but it doesn’t stop there. Things like anonymous methods and iterators have been around in Ruby for quite some time. If you’ve got ten minutes to spare, I highly recommend checking Ruby out. A good place to start is at Try Ruby! which is a browser based Interactive Ruby Prompt, or irb to those in the known. The site even sports a Ruby tutorial, just type “help” and follow the instructions. The Ruby syntax might be a bit unfamiliar at first, but you’ll get the hang of it in no-time. If you want to become a Ruby-expert, you can read the first edition of Dave Thomas’ excellent “Programming Ruby: The Pragmatic Programmers’ Guide” aka “The Pickaxe Book” online, or you can order the second edition from Amazon.

Here are some cool Ruby statements to try:

(3..6).each {|num| puts num}


(1..10).collect {|x| x*x}


def remember(&p)
    @block = p
end

remember {|name| puts "Hello, " + name + "!"}

@block.call("Your name here")


If you get the hang of things, and would like “the Java killer” to be a part of your tool chest. Just clickonce on the “Ruby One Click installer”.