[MacRuby] #1454: Method.arity returns -1 for #initialize method with one argument

MacRuby ruby-noreply at macosforge.org
Sat Feb 18 21:16:10 PST 2012


#1454: Method.arity returns -1 for #initialize method with one argument
------------------------------------+---------------------------------------
 Reporter:  mrada@…                 |       Owner:  lsansonetti@…        
     Type:  defect                  |      Status:  new                  
 Priority:  blocker                 |   Milestone:                       
Component:  MacRuby                 |    Keywords:                       
------------------------------------+---------------------------------------

Comment(by jballanc@…):

 This is, oddly enough, the correct behavior. In the 1.9 series, Ruby
 started always reporting arity -1 for #new. If you want the actual arity
 of the initialize method, you have to be explicit:

  {{{

 irb(main):001:0> class Test
 irb(main):002:1>   def initialize(arg)
 irb(main):003:1>   end
 irb(main):004:0> end
 => nil
 irb(main):005:0> Test.method(:new).arity
 => -1
 irb(main):006:0> Test.instance_method(:initialize).arity
 => 1
 }}}

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/1454#comment:2>
MacRuby <http://macruby.org/>



More information about the macruby-tickets mailing list