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 © Microsoft Corporation. All rights reserved.

class SomeClass
… define_method(:initialize) do |*args|
… puts args.join(", ")
… end
… end
=> #Proc:[email protected]: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:[email protected]: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 © Microsoft Corporation. All rights reserved.

class SomeClass
… define_method(:initialize) do |*args|
… puts args.join(", ")
… end
… end
=> #Proc:[email protected]: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:[email protected]: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)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs