Gregory Brown
12/15/2008 4:08:00 AM
On Sun, Dec 14, 2008 at 7:42 PM, John Carter <john.carter@tait.co.nz> wrote:
> On Mon, 15 Dec 2008, Yukihiro Matsumoto 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?
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