On Fri, Aug 25, 2006 at 08:46:54AM +0900, Rick DeNatale wrote:
> On 8/24/06, Mauricio Fernandez <mfp / acm.org> wrote:
> >
> >class X; end
> >module Y; class ::X; def foo; "X#foo"; end end end
                   ==
This is what my message was about; you omitted it in your irb session.

> >X.new.foo                                          # => "X#foo"
> 
> Really? Was this under 1.8.x or 1.9, 

Under

RUBY_VERSION                   # => "1.8.5"
RUBY_RELEASE_DATE              # => "2006-07-07"

> I'd be surprised if it was either, a gedanken experiment perhaps?

No. I ran that code under xmpfilter
  http://eigenclass.org/hiki.rb?ruby+xmpfilter+0.2.0

It's pretty convenient for ruby-talk postings, and the output is much easier
to read than irb transcripts.

> irb(main):001:0> class X
> irb(main):002:1> end
> => nil
> irb(main):003:0> module Y; class X; def foo; "X#foo"; end; end
                             ========
	              this is not the code I wrote (it's missing the ::)
> irb(main):004:1> end
> => nil
> iirb(main):005:0> X.new.foo
> NoMethodError: undefined method `foo' for #<X:0xb7d4f560>
>        from (irb):6
>        from :0
> irb(main):006:0> Y::X.new.foo
> => "X#foo"
[...]

With the original code:

irb(main):001:0> class X; end
=> nil
irb(main):002:0> module Y; class ::X; def foo; "X#foo"; end end end
=> nil
irb(main):003:0> X.new.foo
=> "X#foo"

(definitely harder to read :)

-- 
Mauricio Fernandez  -   http://eigenclass.org   -  singular Ruby