From: Kevin Smith Date: 2000-12-28T04:07:04+09:00 Subject: [ruby-talk:8134] Re: Method as block to method Nathaniel Talbott wrote: >I find myself wanting to pass a method as the block to another method on a >fairly regular basis, and I don't really like how the code turns out. >Currently it looks like this: > > result.addFaultListener(self, &(method(:addFault).to_proc)) > >which just doesn't seem like it makes the intent very clear (and it's not >very memorable for the next time I want to do it). GTK expects you to pass a code block any time you want to respond to a signal (event). But my coding style wants each event handler to be a method doXxxxx. Here's what I've done so far (and I suspect it can become a little cleaner and/or more automated): toolbar.append_item('Check Mail', 'Check server for new mail', '', icon, proc do doCheckMail end) Basically, it's the "proc do doCheckMail end" that passes the doCheckMail method in as a block. Of course, it's easy when I don't care about parameters or return values, as in this case. Is that along the lines of what you were asking about? Kevin