# \_\_PRETTY\_\_FUNCTION\_\_ for Ruby?

**URL:** <https://www.ruby-forum.com/t/pretty-function-for-ruby/155625>\
**Category:** Ruby\
**Created:** [December 14, 2008, 10:31pm UTC](https://www.ruby-forum.com/t/pretty-function-for-ruby/155625 "2008-12-14T22:31:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![amin1426](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4da419/32.png) [@amin1426](https://www.ruby-forum.com/u/amin1426)\
**Post date:** [December 14, 2008, 10:31pm UTC](https://www.ruby-forum.com/t/pretty-function-for-ruby/155625/1 "2008-12-14T22:31:09Z")

</div>

We have **FILE** and **LINE** …

So it would be nice to have **PRETTY\_FUNCTION**?

Is there one or do I have to roll my own out of “caller(1)[0]”?

John C. Phone : (64)(3) 358 6639  
Tait Electronics Fax : (64)(3) 359 4632  
PO Box 1645 Christchurch Email : removed\_email\_address@domain.invalid  
New Zealand

---

<div class="post-metadata">

**Author:** ![amin1426](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4da419/32.png) [@amin1426](https://www.ruby-forum.com/u/amin1426)\
**Post date:** [December 15, 2008, 12:08am UTC](https://www.ruby-forum.com/t/pretty-function-for-ruby/155625/2 "2008-12-15T00:08:51Z")

</div>

Hi,

In message “Re: **PRETTY\_\_FUNCTION** for Ruby?”  
on Mon, 15 Dec 2008 06:23:08 +0900, John C.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

|We have **FILE** and **LINE** …  
|  
|So it would be nice to have **PRETTY\_FUNCTION**?  
|  
|Is there one or do I have to roll my own out of “caller(1)[0]”?

You mean **method** in 1.9?

```
          matz.

```

---

<div class="post-metadata">

**Author:** ![amin1426](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4da419/32.png) [@amin1426](https://www.ruby-forum.com/u/amin1426)\
**Post date:** [December 15, 2008, 1:50am UTC](https://www.ruby-forum.com/t/pretty-function-for-ruby/155625/3 "2008-12-15T01:50:01Z")

</div>

On Mon, 15 Dec 2008, Yukihiro M. wrote:

> |We have **FILE** and **LINE** …  
> |  
> |So it would be nice to have **PRETTY\_FUNCTION**?  
> |  
> |Is there one or do I have to roll my own out of “caller(1)[0]”?
> 
> You mean **method** in 1.9?

Ah! Sorry! I was looking under the wrong name…

Now, thank you, I’m looking in the right place so I see…

ruby --version  
ruby 1.8.7 (2008-06-20 patchlevel 22) [i686-linux]  
$ ruby -e ‘def foo;p **method** ;end;foo’  
:foo

Are you’re saying that this behaviour change in 1.9?

John C. Phone : (64)(3) 358 6639  
Tait Electronics Fax : (64)(3) 359 4632  
PO Box 1645 Christchurch Email : removed\_email\_address@domain.invalid  
New Zealand

---

<div class="post-metadata">

**Author:** ![amin1426](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4da419/32.png) [@amin1426](https://www.ruby-forum.com/u/amin1426)\
**Post date:** [December 15, 2008, 2:43am UTC](https://www.ruby-forum.com/t/pretty-function-for-ruby/155625/4 "2008-12-15T02:43:11Z")

</div>

Hi,

In message “Re: **PRETTY\_\_FUNCTION** for Ruby?”  
on Mon, 15 Dec 2008 09:42:01 +0900, John C.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

|ruby --version  
|ruby 1.8.7 (2008-06-20 patchlevel 22) [i686-linux]  
|$ ruby -e ‘def foo;p **method** ;end;foo’  
|:foo  
|  
|Are you’re saying that this behaviour change in 1.9?

No, 1.8.7 just added a lot of 1.9 features recently.

```
          matz.

```

---

<div class="post-metadata">

**Author:** ![amin1426](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4da419/32.png) [@amin1426](https://www.ruby-forum.com/u/amin1426)\
**Post date:** [December 15, 2008, 5:15am UTC](https://www.ruby-forum.com/t/pretty-function-for-ruby/155625/5 "2008-12-15T05:15:47Z")

</div>

On Sun, Dec 14, 2008 at 7:42 PM, John C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Ah! Sorry! I was looking under the wrong name…
> 
> Now, thank you, I’m looking in the right place so I see…
> 
> ruby --version  
> ruby 1.8.7 (2008-06-20 patchlevel 22) [i686-linux]  
> $ ruby -e ‘def foo;p **method** ;end;foo’  
> :foo
> 
> Are you’re saying that this behaviour change in 1.9?

Doesn’t look like so:

sandal:Desktop $ ruby -v  
ruby 1.9.1 (2008-10-28 revision 19983) [i386-darwin9.4.0]  
sandal:Desktop $ irb

> > **method**  
> > =\> :irb\_binding  
> > def foo  
> > **method**  
> > end  
> > =\> nil  
> > foo  
> > =\> :foo

Just keep in mind that Ruby 1.8.7 isn’t a compatible Ruby 1.8 version.  
It’s meant for um… I don’t really know what, and if you want your  
code to run on Ruby 1.8.6 (which is pretty important if you plan to  
support 1.8 at all, IMO), it’s not there:

sandal:prawn $ ruby -v  
ruby 1.8.6 (2008-08-11 patchlevel 287) [i686-darwin9.4.0]  
sandal:prawn $ irb

> > **method**  
> > NameError: undefined local variable or method ` **method** ’ for  
> > main:Object  
> > from (irb):1  
> > from :0
