From: sergio <sde...@gm...> - 2007-08-29 17:47:30
|
On 29/ago/07, at 01:18, Laurent Sansonetti wrote: >> this is my first post to this list. > > Welcome! thanks! >> [...] >> /Library/Frameworks/RubyCocoa.framework/Versions/A/Resources/ruby/ >> osx/ >> objc/oc_import.rb:318:in `_ns_behavior_method_added': Cannot override >> Objective-C method 'awakeFromInsert' with Ruby method >> #awakeFromInsert, they should both have the same number of arguments. >> (expected arity 0, got -1) (RuntimeError) > The problem here is that an empty block (proc {}) has an arity of -1, > for an unknown reason. But a block with an empty argument list (proc > {||}) will have an arity of 0. So normally if you call define_method > with blocks with an empty argument list, you should not get the > exception. perfect! it works with an empty argument list... I did some googling and I found that the arity conventions in ruby 1.9 could change... I don't know what is the official source of information about 1.9, but I found this interesting: (1) http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/120252 (2) http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/11029? help-en (3) http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/249149 in short, it seems that in 1.9 both proc{}.arity and proc{||}.arity shall return 0 -- by definition (1) -- although it seems (3) that in some not so old ruby 1.9.0 release both returned -1. in any case, this would be a change from how it works now. if what I am saying is just crap, simply ignore it... :-) best sergio |