From: timsuth@... (Tim Sutherland) Date: 2004-06-19T17:28:20+09:00 Subject: Re: a newbie question about main, Object... In article <871xkcdx44.fsf@optushome.com.au>, George Ogata wrote: >Kevin Bullock 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