From: dblack@... Date: 2003-05-09T08:16:04+09:00 Subject: Re: Can a global be a constant? Hi -- On Fri, 9 May 2003, Jim Freeze wrote: > Ok, so how would you > access the state object in the code below without > making it a global as I did? > > class App > State = ::Struct.new(:debug, :verbose) > $state = State.new(true, false) > def main > Work.new > end > end > > class Work > def initialize > puts $state.debug > end > end > > App.new.main Would this be suitable? class App class << self attr_reader :state end State = Struct.new(:debug, :verbose) @state = State.new(true, false) def main Work.new end end class Work def initialize puts App.state.debug end end App.new.main David -- David Alan Black home: dblack@superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav