Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: Mutual require problem
Yuu
3/2/2006 10:39:00 PM
Adam Shelly wrote:
> On 3/2/06, renaud delbru <renaud.delbru@deri.org> wrote:
>> > def self.print
>> > class Test < A
>> > end
>>
>> And the result during the execution :
>> workspace/test-divers/main.rb:10: uninitialized constant Test
>> (NameError)
>>
>
>
> Circular requires are a bad thing.
> See
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-t...
.
>
> To avoid them, try the ruby equivalent of a forward declaration: In
> test.rb, replace
>> require 'main'
> with
>> class A; end
..or, if possible, try to not have both files referencing
eachother. It is *usually* not necessary.
> -Adam
E
--
Posted via
http://www.ruby-...
.
2 Answers
Guest
3/3/2006 10:06:00 AM
0
Thank you adam for your answers,
I have resolved the problem with a toplevel file which contains
the sequence of require.
Bye.
--
Renaud Delbru
--
Posted via
http://www.ruby-...
.
Han Holl
3/3/2006 12:27:00 PM
0
Another useful technique here is autoloading.
There are cases where require is needed, but in general autoload is much
better.
Looser coupling, less memory use, faster programs.
Cheers,
Han Holl
On 3/3/06, Guest <renaud.delbru@deri.org> wrote:
>
> Thank you adam for your answers,
>
> I have resolved the problem with a toplevel file which contains
> the sequence of require.
>
> Bye.
>
> --
> Renaud Delbru
>
> --
> Posted via
http://www.ruby-...
.
>
>
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: Mutual require problem
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password