From: Urabe Shyouhei Date: 2011-12-07T10:01:33+09:00 Subject: [ruby-core:41510] Re: [ruby-trunk - Bug #5694][Open] Proc#arity doesn't take optional arguments into account. trans wrote: > On Sunday, December 4, 2011 3:02:29 PM UTC-5, NARUSE, Yui wrote: >> >> >> After some consideration, I'm wondering why following code is not used. >> There is already a method or proc object in usual use case? >> >> begin >> obj.__send__(callback, attributes) >> rescue ArgumentError >> obj.__send__(callback) >> end >> > > I avoid rescue clauses when I can because I am under the assumption that > they will (almost) always be less efficient then a conditional check. As of ruby 1.9 a begin ... end block is almost no cost. To raise an exception is the hard part. So the above code works efficiently as long as that callback takes attributes arguments.