# Define\_method behaves different than MRI

**URL:** <https://www.ruby-forum.com/t/define-method-behaves-different-than-mri/177062>\
**Category:** IronRuby\
**Created:** [October 10, 2009, 6:42pm UTC](https://www.ruby-forum.com/t/define-method-behaves-different-than-mri/177062 "2009-10-10T18:42:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![barby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c57346/32.png) [@barby](https://www.ruby-forum.com/u/barby)\
**Post date:** [October 10, 2009, 6:42pm UTC](https://www.ruby-forum.com/t/define-method-behaves-different-than-mri/177062/1 "2009-10-10T18:42:19Z")

</div>

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](http://flanders.co.nz)  
Twitter: [http://twitter.com/casualjim](http://twitter.com/casualjim)  
Author of IronRuby in Action ([http://manning.com/carrero](http://manning.com/carrero))

---

<div class="post-metadata">

**Author:** ![barby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c57346/32.png) [@barby](https://www.ruby-forum.com/u/barby)\
**Post date:** [October 12, 2009, 5:52am UTC](https://www.ruby-forum.com/t/define-method-behaves-different-than-mri/177062/2 "2009-10-12T05:52:02Z")

</div>

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

Tomas

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] 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](http://flanders.co.nz)  
Twitter: [http://twitter.com/casualjim](http://twitter.com/casualjim)  
Author of IronRuby in Action ([http://manning.com/carrero](http://manning.com/carrero))
