Is available online! How about that? There’s a second edition out, and the third edition is soon to head to the presses. I have the third edition PDF, and that’s what I’ve been blagging about. But, if you’re broke (or cheap) and want to learn ruby, I highly reccomend the book.

 

I’m feeling kinda tired, so the chapter on exceptions is gonna be a short one.

Turns out I was getting sick. Bleh. Yay for day-quil! Anyway, the chapter in the book on Exceptions is kinda small. Exceptions work just about exactly the same as they do in Java. Throw and catch aren’t quite the same, however. In ruby you “fail” or “raise” an exception. “throw” and “catch” work for bailing out of loops.

In ruby, exceptions are caught by using “rescue” and behave just like catch in Java. There is also a “finally” type clause, called “ensure”; behaves the exact same way it does in Java. Ruby has the concept of a “retry” which is kinda neat. There is great potential for infinite loops, however, so take care. “raise” in ruby behaves the same way as “throw” in java.

“catch” and “throw” are different. You use it to bail from a loop. Ruby will crawl up the stack when you throw something, looking for the location to catch it. Then it’ll jump outside that loop and finish. I personally think that’s pretty spagetti code inducing, but I can see where it might have its usefulness.

And that’s it. This blag post is really almost as long as the actual chapter. Next up is I/O.

 

How about that: “Facets” of ruby. I’m so witty, it hurts. I’ll quickly go over methods and a sentence or two on expressions. Parallel assignments get a few more words, since it’s new. A bit on boolean logic, and case statements, because they’re cool. Finishing up with loops and a few words on scoping. Continue reading »

 

They behave just like regular expressions in any other language. No big surprise there. There’s a lot to read about regular expressions, but not a whole lot I care to talk about. There’s only a few things that are ruby specific to the regular expressions.

Continue reading »

 

I only got about three-quarters of the way through the chapter. I got distracted by redoing the theme on this site. Whoops. It does look prettier now, though, doesn’t it? Doesn’t it?!? Continue reading »

© 2011 Shlrm.org Blag Suffusion theme by Sayontan Sinha