# Instance\_eval

**URL:** <https://www.ruby-forum.com/t/instance-eval/125457>\
**Category:** Rails\
**Created:** [January 9, 2008, 9:00am UTC](https://www.ruby-forum.com/t/instance-eval/125457 "2008-01-09T09:00:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ayyanar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/82dd89/32.png) [@ayyanar](https://www.ruby-forum.com/u/ayyanar)\
**Post date:** [January 9, 2008, 9:00am UTC](https://www.ruby-forum.com/t/instance-eval/125457/1 "2008-01-09T09:00:08Z")

</div>

Can anyone explain the use of instance\_eval and provide the example?

---

<div class="post-metadata">

**Author:** ![ayyanar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/82dd89/32.png) [@ayyanar](https://www.ruby-forum.com/u/ayyanar)\
**Post date:** [January 9, 2008, 9:27am UTC](https://www.ruby-forum.com/t/instance-eval/125457/2 "2008-01-09T09:27:52Z")

</div>

On 09 Jan 2008, at 09:00, Ayyanar from Aspire Systems wrote:

> Can anyone explain the use of instance\_eval and provide the example?

Google “instance\_eval” first results in the list:  
[http://redhanded.hobix.com/inspect/testingDeeplyWithInstance\_eval.html](http://redhanded.hobix.com/inspect/testingDeeplyWithInstance_eval.html)  
[http://toolmantim.com/article/2006/11/29/instance\_eval\_brings\_sexy\_back](http://toolmantim.com/article/2006/11/29/instance_eval_brings_sexy_back)

> **[Evaluation Options in Ruby](https://www.infoq.com/articles/eval-options-in-ruby/)**
>
> Jay Fields, known for his cutting edge work defining BNLs (Business Natural Languages) delivers a code-rich explanation of eval, class\_eval, and instance\_eval, in the context of implementing domain-specific languages in Ruby.

[http://blog.jayfields.com/2007/03/ruby-instanceeval-and-classeval-](http://blog.jayfields.com/2007/03/ruby-instanceeval-and-classeval-)  
method.html

Best regards

Peter De Berdt

---

<div class="post-metadata">

**Author:** ![ayyanar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/82dd89/32.png) [@ayyanar](https://www.ruby-forum.com/u/ayyanar)\
**Post date:** [January 9, 2008, 10:00am UTC](https://www.ruby-forum.com/t/instance-eval/125457/3 "2008-01-09T10:00:13Z")

</div>

The third links is fruitful.

> **[Evaluation Options in Ruby](https://www.infoq.com/articles/eval-options-in-ruby/)**
>
> Jay Fields, known for his cutting edge work defining BNLs (Business Natural Languages) delivers a code-rich explanation of eval, class\_eval, and instance\_eval, in the context of implementing domain-specific languages in Ruby.

Can one one simplify it more?

I think, it is used to include a variable in the instance which is not  
originally available in the class.
