# Trouble with mod\_eval

**URL:** <https://www.ruby-forum.com/t/trouble-with-mod-eval/97576>\
**Category:** Ruby\
**Created:** [July 8, 2006, 2:07am UTC](https://www.ruby-forum.com/t/trouble-with-mod-eval/97576 "2006-07-08T02:07:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [July 8, 2006, 2:07am UTC](https://www.ruby-forum.com/t/trouble-with-mod-eval/97576/1 "2006-07-08T02:07:36Z")

</div>

I have installed Ruby upon OS X recently and I am working on a small  
script just to test out some new techniques and trying to learn some  
new languages. Currently I am trying to work out a little code to  
develop new methods on the fly. I have read about mod\_eval, and trying  
to use:

self.mode\_eval(mod)

Where mod is a variable method. Unfortunately I can not seem to get it  
right, every exceution I try results in:

undefined method `mod\_eval’ for #Bot:0x328258

Where #Bot:0x328258 is the class that is calling mod\_eval(). I have  
looked for documentation on this but I can not seem to find anything.  
So any help would be greatly appreciated.

Am I missing something small that I should be requiring, or am I  
missing the whole idea completely?

Thanks.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [July 8, 2006, 3:30am UTC](https://www.ruby-forum.com/t/trouble-with-mod-eval/97576/2 "2006-07-08T03:30:11Z")

</div>

On 7/8/06, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> undefined method `mod\_eval’ for #Bot:0x328258

This is a clue. See below.

> Where #Bot:0x328258 is the class that is calling mod\_eval(). I have  
> looked for documentation on this but I can not seem to find anything.  
> So any help would be greatly appreciated.
> 
> Am I missing something small that I should be requiring, or am I  
> missing the whole idea completely?
> 
> Thanks.

Well, there’s a couple of things here:

1. There is no method that I know of in Ruby called ‘mod\_eval’ (or  
‘mode\_eval’). Perhaps you mean ‘module\_eval’.

2. ‘module\_eval’ only works in the context of a Module or Class  
definition.

HTH

Regards,  
Sean
