# Method introspection question

**URL:** <https://www.ruby-forum.com/t/method-introspection-question/51071>\
**Category:** Ruby\
**Created:** [December 25, 2005, 4:14pm UTC](https://www.ruby-forum.com/t/method-introspection-question/51071 "2005-12-25T16:14:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![amrangaye](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@amrangaye](https://www.ruby-forum.com/u/amrangaye)\
**Post date:** [December 25, 2005, 4:14pm UTC](https://www.ruby-forum.com/t/method-introspection-question/51071/1 "2005-12-25T16:14:08Z")

</div>

Hello

Is there anyway to get back the definition of a method within a running  
program [or irb session]?

For example, if I declare a method:

def hello  
puts “Hello”  
end

is there anything like hello.source to get back hello’s code?

Thanks.

---

<div class="post-metadata">

**Author:** ![amrangaye](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@amrangaye](https://www.ruby-forum.com/u/amrangaye)\
**Post date:** [December 25, 2005, 6:34pm UTC](https://www.ruby-forum.com/t/method-introspection-question/51071/2 "2005-12-25T18:34:05Z")

</div>

amrangaye wrote:

> is there anything like hello.source to get back hello’s code?
> 
> Thanks

look at ParseTree or Scrit\_lines\_\_,  
[http://blog.zenspider.com/archives/parsetree/index.html](http://blog.zenspider.com/archives/parsetree/index.html)  
[http://redhanded.hobix.com/inspect/whoaScript\_lines\_\_.html](http://redhanded.hobix.com/inspect/whoaScript_lines__.html).

---

<div class="post-metadata">

**Author:** ![amrangaye](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@amrangaye](https://www.ruby-forum.com/u/amrangaye)\
**Post date:** [December 26, 2005, 5:23am UTC](https://www.ruby-forum.com/t/method-introspection-question/51071/3 "2005-12-26T05:23:17Z")

</div>

amrangaye wrote:

> is there anything like hello.source to get back hello’s code?

[http://lazaridis.com/case/lang/ruby/base.html#sayYourClassCode](http://lazaridis.com/case/lang/ruby/base.html#sayYourClassCode)

If you implement an solution, please contact me via private email, thus  
I can update the document.

This way evaluators (or users) can immediately detect (and use) the  
functionality.

> Thanks.

…
