Define_method behaves different than MRI

Hi

this used to work but now doesn’t anymore

» ir
IronRuby 0.9.1.0 on .NET 2.0.50727.4927
Copyright (c) Microsoft Corporation. All rights reserved.

class SomeClass
… define_method(:initialize) do |*args|
… puts args.join(", ")
… end
… end
=> #Proc:0x0000056@:2(unknown)
SomeClass.new 1, 4, 6, 3
:0: wrong number of arguments (4 for 0) (ArgumentError)

exit

  • C:\dev
    » irb
    irb(main):001:0> class SomeClass
    irb(main):002:1> define_method(:initialize) do |args|
    irb(main):003:2
    puts args.join(", ")
    irb(main):004:2> end
    irb(main):005:1> end
    => #Proc:0x0442490c@:2(irb)
    irb(main):006:0> SomeClass.new 1, 4, 6, 3
    1, 4, 6, 3
    => #SomeClass:0x4416c08
    irb(main):007:0>

Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)

Have a fix for this.
Thanks for the simple repro!

Tomas

From: [email protected]
[mailto:[email protected]] On Behalf Of Ivan Porto
Carrero
Sent: Saturday, October 10, 2009 9:41 AM
To: ironruby-core
Subject: [Ironruby-core] define_method behaves different than MRI

Hi

this used to work but now doesn’t anymore

» ir
IronRuby 0.9.1.0 on .NET 2.0.50727.4927
Copyright (c) Microsoft Corporation. All rights reserved.

class SomeClass
… define_method(:initialize) do |*args|
… puts args.join(", ")
… end
… end
=> #Proc:0x0000056@:2(unknown)
SomeClass.new 1, 4, 6, 3
:0: wrong number of arguments (4 for 0) (ArgumentError)

exit

  • C:\dev
    » irb
    irb(main):001:0> class SomeClass
    irb(main):002:1> define_method(:initialize) do |args|
    irb(main):003:2
    puts args.join(", ")
    irb(main):004:2> end
    irb(main):005:1> end
    => #Proc:0x0442490c@:2(irb)
    irb(main):006:0> SomeClass.new 1, 4, 6, 3
    1, 4, 6, 3
    => #SomeClass:0x4416c08
    irb(main):007:0>

Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)