Learning Ruby!

I’m learning Ruby! It’s fun to do simple things in a new (for me) language. Hello worlds are always fun. Here’s what I just did!

lyric1 = " bottles of beer on the wall"
lyric2 = " bottles of beer"
lyric3 = "take on down, pass it around, "
beers = 99

while beers > 0
    puts beers.to_s + lyric1
    puts beers.to_s + lyric2
    puts lyric3
    beers = beers - 1
    if beers == 1
        lyric1["bottles"] = "bottle"
        lyric2["bottles"] = "bottle"
    puts beers.to_s + lyric1

Pretty basic, I know, but I’m having fun. Soon I’ll be moving on to Ruby on Rails and writing kick-ass web apps.

Here are the resources I’ve been using (the one thing I’m missing is an exact language reference – like, do I need semi-colons? do both ” and ‘ work for string literals? does indentation matter (like in python)?):

I started here – try ruby! (in your browser). This one rocks! Try it out in your browser, you can’t say no to learning when it’s this easy!
I’ve also been using Learn to Program, by Chris Pine and Programming Ruby: The Pragmatic Programmer’s Guide. The former is the one which had me write my 99 bottles of beer on the wall generator.

Ok, next up, I need to answer my own questions and report back with a good lexical reference!

update Here are my answers – semi colons are only needed if you have more than one command per line, indention doesn’t seem to matter (code works either way) and the same for double versus single quote.