[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Prevents multiple includes of the same module

user@domain.invalid

10/11/2008 4:13:00 PM

Hello, one module defines several CONSTANTS
As it is required from few classes I get
warning: already initialized constant FOO

How can I prevents the redefinition of theses CONSTANTS ? It's just
because it pollutes my screen during unit testing...

Thanks
1 Answer

TPReal

10/11/2008 5:37:00 PM

0

Zouplaz wrote:
> Hello, one module defines several CONSTANTS
> As it is required from few classes I get
> warning: already initialized constant FOO
>
> How can I prevents the redefinition of theses CONSTANTS ? It's just
> because it pollutes my screen during unit testing...
>
> Thanks

It's not clear what's your problem. If you do this:

module M;A=8;end
class K;include M;end
class L;include M;end

you get no warning as the constants is not redefined by including the
module. It just becomes accessible as K::A and L::A. I think you should
paste an isolated sample to illustrate your problem.

TPR.
--
Posted via http://www.ruby-....