From: Gennady Date: 2003-05-09T08:51:29+09:00 Subject: Re: Can a global be a constant? It seems like you missed David Black's post, it may be the neat solution you are looking for: http://www.ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-talk/71000 Gennady. ----- Original Message ----- From: "Jim Freeze" To: "ruby-talk ML" Sent: Thursday, May 08, 2003 4:37 PM Subject: Re: Can a global be a constant? > On Friday, 9 May 2003 at 8:23:52 +0900, Hal E. Fulton wrote: > > > > Not a stupid question... maybe my assumptions > > don't work for you, but what I was thinking > > was something like: > > > > class State > > @@debug = nil > > @@verbose = nil > > > > def State.debug > > @@debug > > end > > > > def State.debug=(val) > > @@debug = val > > end > > > > def State.verbose > > @@verbose > > end > > > > def State.verbose=(val) > > @@verbose = val > > end > > > > class App > > def main > > State.debug = true > > State.verbose = false > > Work.new > > end > > end > > > > class Work > > def initialize > > puts State.debug > > end > > end > > > > App.new.main > > > > > > Hal > > Yes. That is the truly global solution. I was > trying to do that but was getting lost somewhere. > > Is there a neater (read more concise) way to define State with > maybe a << class_attr_accessor maybe? > > A couple of requirements that would be nice: > 1) Only the creator of the state can change it > 2) Classes at most have to do an include to get > access to the state. > > -- > Jim Freeze > ---------- > VMS is like a nightmare about RSX-11M. > >