From: David Garamond Date: 2004-10-14T01:25:51+09:00 Subject: Re: Sharing variables across methods Warren Brown wrote: > MyCGI = CGI.new('html3') > MyConn = PGconn.connect(...) > > def foo > MyCGI.exec(...) > MyCGI.out { ... } > end Sigh. Now why didn't I think of that? My mind is so used to thinking that constants can only be used for simple things like 'Foo = 3'. Thanks! > A better, but much more verbose way would be to instantiate a > singleton class for your globals: > > require 'singleton' > > class Globals > include Singleton > attr_accessor(:cgi,:conn) > end > > Globals.instance.cgi = CGI.new('html3') [snip] Nah... that is _so_ much typing and not significantly better than $cgi :-) -- dave