# Where is the define\_singleton\_method method?

**URL:** <https://www.ruby-forum.com/t/where-is-the-define-singleton-method-method/113240>\
**Category:** Ruby\
**Created:** [August 29, 2007, 6:28am UTC](https://www.ruby-forum.com/t/where-is-the-define-singleton-method-method/113240 "2007-08-29T06:28:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![taq](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7c8e57/32.png) [@taq](https://www.ruby-forum.com/u/taq)\
**Post date:** [August 29, 2007, 6:28am UTC](https://www.ruby-forum.com/t/where-is-the-define-singleton-method-method/113240/1 "2007-08-29T06:28:20Z")

</div>

I just got the svn trunk and was testing some new stuff, but could not  
find the define\_singleton\_method:

irb(main):001:0\> [RUBY\_VERSION,RUBY\_RELEASE\_DATE]  
=\> [“1.9.0”, “2007-08-28”]  
irb(main):002:0\> a = “”  
=\> “”  
irb(main):003:0\> a.define\_singleton\_method(:foo){|x| x + 1}  
NoMethodError: undefined method `define\_singleton\_method’ for “”:String

Running out of irc the same two lines above I get the same results:

[taq@~/code/ruby/1.9]ruby1.9 dsm.rb  
dsm.rb:2:in `method_missing': undefined method`define\_singleton\_method’  
for “”:String (NoMethodError)  
from dsm.rb:2:in `’

Am I missing something?

Thanks!

---

<div class="post-metadata">

**Author:** ![taq](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7c8e57/32.png) [@taq](https://www.ruby-forum.com/u/taq)\
**Post date:** [August 29, 2007, 9:45am UTC](https://www.ruby-forum.com/t/where-is-the-define-singleton-method-method/113240/2 "2007-08-29T09:45:42Z")

</div>

Hi,

At Wed, 29 Aug 2007 13:28:24 +0900,  
=?utf-8?Q?Eust=c3=a1quio\_Rangel?= wrote in [ruby-talk:266637]:

> I just got the svn trunk and was testing some new stuff, but could not  
> find the define\_singleton\_method:

No such method is defined.

---

<div class="post-metadata">

**Author:** ![taq](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7c8e57/32.png) [@taq](https://www.ruby-forum.com/u/taq)\
**Post date:** [August 29, 2007, 12:26pm UTC](https://www.ruby-forum.com/t/where-is-the-define-singleton-method-method/113240/3 "2007-08-29T12:26:35Z")

</div>

Nobuyoshi N. wrote:

> No such method is defined.

Thanks for your answer, but now I’m kind of lost here. There’s a  
reference of the method here:  
[http://www.ruby-doc.org/core-1.9/classes/Object.html#M000330](http://www.ruby-doc.org/core-1.9/classes/Object.html#M000330)

And here, where I got the previous samples:  
[http://eigenclass.org/hiki.rb?Changes+in+Ruby+1.9#l29](http://eigenclass.org/hiki.rb?Changes+in+Ruby+1.9#l29)

And also on the Changelog, from Matz!:  
Mon Oct 9 01:56:34 2006 Yukihiro M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

- eval.c (rb\_obj\_define\_method): add new method  
Kernel#define\_singleton\_method. [ruby-list:42851]

I got the latest trunk using:  
svn co [http://svn.ruby-lang.org/repos/ruby/trunk](http://svn.ruby-lang.org/repos/ruby/trunk) ruby

I searched for rb\_obj\_define\_method on the C code but could not find any  
code for it. Searching for rb\_define\_singleton\_method returns me a lot  
of references of its internal use (as C code) and its definition on  
class.c, but not as a method we can reach from the language, without a  
thing like ‘rb\_define\_method(rb\_mKernel, “define\_singleton\_method”,  
rb\_obj\_instance\_eval, -1);’ there.

So, I’m lost, what happened with this method? 🙂

Thanks again!

---

<div class="post-metadata">

**Author:** ![taq](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7c8e57/32.png) [@taq](https://www.ruby-forum.com/u/taq)\
**Post date:** [August 30, 2007, 8:59pm UTC](https://www.ruby-forum.com/t/where-is-the-define-singleton-method-method/113240/4 "2007-08-30T20:59:55Z")

</div>

Nobuyoshi N. wrote:

> It seems lost at YARV merger. Reverted now.

Thank you!

---

<div class="post-metadata">

**Author:** ![taq](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7c8e57/32.png) [@taq](https://www.ruby-forum.com/u/taq)\
**Post date:** [August 30, 2007, 7:08am UTC](https://www.ruby-forum.com/t/where-is-the-define-singleton-method-method/113240/5 "2007-08-30T07:08:16Z")

</div>

Hi,

At Wed, 29 Aug 2007 19:26:39 +0900,  
=?utf-8?Q?Eust=c3=a1quio\_Rangel?= wrote in [ruby-talk:266659]:

> And also on the Changelog, from Matz!:  
> Mon Oct 9 01:56:34 2006 Yukihiro M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
> 
> - eval.c (rb\_obj\_define\_method): add new method  
> Kernel#define\_singleton\_method. [ruby-list:42851]

It seems lost at YARV merger. Reverted now.
