From: Lionel Thiry Date: 2004-04-05T02:09:19+09:00 Subject: Re: good module use? David A. Black a �crit : > On Sun, 4 Apr 2004, Lionel Thiry wrote: >>Bauduin Raphael a �crit : >>>Hi, >>> >>>I thought to create a module to add an instance variable representing >>>the connection to a database: >>> >>>module MyDbModule >>> attr :conn >>> require "postgres" >>> pghost="localhost" >>> pgport=nil >>> pgoptions=nil >>> pgtty=nil >>> dbname="mydb" >>> user='mylogin' >>> password='mypassword' >>> >>>@conn=PGconn.connect(pghost,pgport,pgoptions,pgtty,dbname,user,password) >>> >>>end >> >>To use a module variable through "MyModule.my_var", just prefix the >>variable name in the module with "self." or "@@". > Not exactly; @@var is a class variable; self.var is a method call. If > you want an association between them, you have to write appropriate > methods: Oops, wrote my advice too fast! ;) Well, I've found how I could write such a mistake... Learning from mistakes is always a good thing, isn't it? (but teaching them is not, sorry!) Lio