Not sure I understand:

irb> sefl
=> main

> ruby -e "puts self" => main

why are these different?

./alex
--
.w( the_mindstorm )p.


On 6/13/06, Joel VanderWerf <vjoel / path.berkeley.edu> wrote:
> Alexandru Popescu wrote:
> > Ohhh... indeed I have tried using irb. Weird!
>
> In irb, 'def foo; end' apparently creates a public method of the "main"
> object:
>
> irb(main):001:0> self
> => main
> irb(main):002:0> def foo; puts "FOO"; end
> => nil
> irb(main):003:0> self.foo
> FOO
> => nil
> irb(main):004:0> class << self; puts
> (methods-private_methods).grep(/foo/); end
> foo
> => nil
>
> So the "top level" of irb differs from the normal top level of ruby.
>
> --
>       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
>
>
>