Archive for October, 2007

One-line rescue, and beautiful sounds

I wanted to see if my WAV file wrapper would work in 1.9. I didn’t see any reason why it shouldn’t, but little things change here and there, so you never know.

Well, something did go wrong. I know this is sloppy, but I was getting the octave of notes from something like this:

note.match(/\d+$/)[0] rescue 4

It turns out that NoMethodError is no longer a descendant of StandardError, and is thus no longer rescued by that rescue. So when the note didn’t have its octave in tow, note.match(/\d+$/) was returning nil, and nil doesn’t have a method [], but it would cruise right past the rescue clause.

A quick fix (a simple exercise left for the reader), and Ruby 1.9 is making me beautiful sounds:

Comments (1)

Automating testing

I suppose you could say I didn’t believe it. But I gave it a shot anyway.

I spent about an hour on Sunday hacking together a little tool to generate test stubs and the little bit of other setup required for the kind of testing I’d need to do at work. I know it’s only been a day, but I was twice as productive today as normal. And I wasn’t even really testing before.

Now I’m really, actually testing and working faster (and better).

We’ll see if the productivity boost stays, but I sure hope it does.

Comments