On Sat, 19 Jun 2004 17:28:20 +0900, Tim Sutherland <timsuth / ihug.co.nz> wrote:
> 
> 
> In article <871xkcdx44.fsf / optushome.com.au>, George Ogata wrote:
> >Kevin Bullock <kbullock / ringworld.org> writes:
> >
> >> Just some random thoughts I had. Seems like I may have seen this
> >> before... is this an established idiom?
> >
> >There was a time when toplevel defs were *private* instance methods of
> >Object.  The pickaxe says this anyway.  I see nothing in the
> >Changelogs about any intentional change, so my guess is it's a bug.
> >Gurus?
> 
> They still are. This was just an irb thing.
> 
> $ cat > foo.rb
> def hello
>   puts("Hello World")
> end
> 
> "blah".hello
> ^D
> $ ruby foo.rb
> foo.rb:5: private method `hello' called for "blah":String (NoMethodError)
> 
> But in irb
> 
> irb(main):001:0> def hello
> irb(main):002:1>   puts("Hello World")
> irb(main):003:1> end
> => nil
> irb(main):004:0> "blah".hello
> Hello World
> => nil
> 
>