On rereading this and then seeing the thread on asking questions,
methinks I ought to talk a bit about how I came up with this, and how
the rest of you can do likewise when stuck in a simliar situation as
the OP. As you may recall, he wanted to use find, but the method
returned an Array, which doesn't have a find method.
I figured, there's *got* to be *some* useful method on Array. There
wasn't one that I immediately recalled offhand. So I went to the docs
for the Array class, and looked at the methods. Of course there were
things like map/collect, that could be used to loop over it and return
true if it found a match or false if it hit the end, or select that
could be used to construct an array of "hit" elements. But I figured
there was probably a cleaner solution, that would still be clear and
concise, as a one-liner. I didn't know index would take a block...
and stumbling across that was the key.
Upshot: if you want to use method X, that works on class A, but you're
stuck with class B, take a quick stroll through the methods on B, and
see if there's something that can at least be used in a similar way.
If not, maybe there's even something better -- you don't have to solve
all similar problems the exact same way.
Ah, THAT'S where that was hiding! Something in the back of my brain
was saying "any", but my Ruby-fu is a touch out of date so I didn't
dredge up immediately where to look to verify that.
So, revised upshot: do the procedure I recommended on ALL applicable
classes! Start from the current thing and work up the inheritance
chain until you find something suitable.