Monday, February 21, 2011

More about Ruby, Databases and Syntax

So I was extremely lazy this weekend and only spent a couple hours working with Ruby. Awful! However, I think a little time away from actively learning caused a few things to click in my head. Imagine a pair of gears, left to their own devices after hours of meddling and tinkering, that suddenly come together and begin to move. Not smoothly, perhaps, but real motion!

It's hard to describe what clicked for me. The syntax seems to make more sense the more I work with it. While working through Beginning Ruby, I've been typing every bit of code out, then attempting to run it. It's good practice, both to get used to how Ruby is written as well as learning what will cause Ruby to throw up AND how to fix those little problems. How often do you guys do something stupid like this?

class Person
  attr_accessor :name, :age
end

fred = Preson.new
fred.name = "Fred"
fred.age = 35

puts fred.name
puts fred.age

Only to have Ruby throw up everywhere because of two little letters that got switched?

I'm guessing this transposition kind of crap is something that will haunt me FOREVER, but I'll get better at spotting it as I go along.

Also I would like to say that I wrote this bit of example code almost ENTIRELY from memory. So things are sticking. I still have a hard time believing how easy some of this is, but there's still plenty I don't really understand yet. Still, let's not get ahead of ourselves here.

Still working through Chapter 9. I just installed my_sql. How do you pronounce this, anyway? I heard a guy at the meetup a couple weeks ago call it "My Sequel" which seems better than "MY SQL" but I don't know.

2 comments:

  1. Out of curiosity, what version of Ruby are you working with?

    Most people say "My Sequel" although once in a while I hear it referred to as "My S Q L"

    ReplyDelete
  2. Hey Brennan! I'm running 1.8.7 right now. What about you? Making progress?

    I like "My Sequel" better. Thanks for the clarification.

    ReplyDelete