Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

"using namespace" equivalent ?

997 views
Skip to first unread message

killy-kun

unread,
Mar 19, 2006, 9:28:27 AM3/19/06
to
I would like to know if there is in ruby an equivalent to the c++
instruction "using namespace" (in order not to have to prefix things by
there namespace when needed).

James Edward Gray II

unread,
Mar 19, 2006, 10:59:16 AM3/19/06
to

Well, if we are talking about a module, you might be able to include it:

>> module Namespace
>> extend self
>> def some_method
>> puts "Hello!"
>> end
>> end
=> nil
>> Namespace::some_method
Hello!
=> nil
>> include Namespace
=> Object
>> some_method
Hello!
=> nil

Hope that helps.

James Edward Gray II


killy-kun

unread,
Mar 19, 2006, 1:01:30 PM3/19/06
to

Thank you very much !!
That's exactely what I was looking for.
(I was using the "require" instruction, and I thought the "include"
instruction was quite similar, that is why I didn't try it...)

0 new messages