[#1816] Ruby 1.5.3 under Tru64 (Alpha)? — Clemens Hintze <clemens.hintze@...>

Hi all,

17 messages 2000/03/14

[#1989] English Ruby/Gtk Tutorial? — schneik@...

18 messages 2000/03/17

[#2241] setter() for local variables — ts <decoux@...>

18 messages 2000/03/29

[ruby-talk:02099] Re: Scope violated by import via 'require'?

From: matz@... (Yukihiro Matsumoto)
Date: 2000-03-23 04:17:54 UTC
List: ruby-talk #2099
Hi,

In message "[ruby-talk:02084] Scope violated by import via 'require'?"
    on 00/03/22, Clemens Hintze <c.hintze@gmx.net> writes:

|But if I put the definition of the inner module 'Bar' in a file on its
|own called e.g. 'mBar.rb' and 'require' this file during module
|definition of 'Foo', 'Bar' will be known both within 'Foo' and outside
|of it:

Well, it's an expected behavior (at least I as expect it ;-)

require()/load() evaluates the contents of the file at the toplevel.

So by this example:

|   $ cat mBar.rb
|   module Bar
|   end
|
|   $ ruby
|   module Foo
|     require "mBar"
|   end

module Bar is defined at the toplevel.  And in 1.5.x, `::' notation
accesses the constants defined in superclasses too, which makes
Foo::Bar valid.

							matz.

In This Thread