P
Paul Brannan
Why do I get the following arities:
irb(main):005:0> [pbrannan@zaphod tmp]$ irb
irb(main):001:0> RUBY_VERSION
=> "1.6.8"
irb(main):002:0> class Foo; define_method :foo, proc {}; end
=> #<Proc:0x402629e8>
irb(main):003:0> Foo.instance_methodfoo).arity
=> -135401849
irb(main):004:0>
[pbrannan@zaphod tmp]$ irb-1.8
irb(main):001:0> RUBY_VERSION
=> "1.8.1"
irb(main):002:0> class Foo; define_method :foo, proc {}; end
=> #<Proc:0x00000000@(irb):2>
irb(main):003:0> Foo.instance_methodfoo).arity
=> 1
In the first case I get a completely unexpected arity; I suspect this is
a bug that was fixed in 1.8?
In the second I get an arity of 1, but I can clearly call the method
with 0 or 3 arguments:
irb(main):004:0> Foo.new.foo()
=> nil
irb(main):005:0> Foo.new.foo(1, 2, 3)
=> nil
I would expect that a method that can take any number of arguments would
have an arity of -1. Why is this not the case with methods defined with
define_method()?
Paul
irb(main):005:0> [pbrannan@zaphod tmp]$ irb
irb(main):001:0> RUBY_VERSION
=> "1.6.8"
irb(main):002:0> class Foo; define_method :foo, proc {}; end
=> #<Proc:0x402629e8>
irb(main):003:0> Foo.instance_methodfoo).arity
=> -135401849
irb(main):004:0>
[pbrannan@zaphod tmp]$ irb-1.8
irb(main):001:0> RUBY_VERSION
=> "1.8.1"
irb(main):002:0> class Foo; define_method :foo, proc {}; end
=> #<Proc:0x00000000@(irb):2>
irb(main):003:0> Foo.instance_methodfoo).arity
=> 1
In the first case I get a completely unexpected arity; I suspect this is
a bug that was fixed in 1.8?
In the second I get an arity of 1, but I can clearly call the method
with 0 or 3 arguments:
irb(main):004:0> Foo.new.foo()
=> nil
irb(main):005:0> Foo.new.foo(1, 2, 3)
=> nil
I would expect that a method that can take any number of arguments would
have an arity of -1. Why is this not the case with methods defined with
define_method()?
Paul