On Friday,  9 May 2003 at  7:36:18 +0900, Hal E. Fulton wrote:
> ----- Original Message ----- 
> 
> I sometimes use instance variables as globals at the 
> top level... they act global since they go into Object's 
> class, and if/when I wrap stuff in a class, I don't 
> have to change them all.
> 
> I've also noticed that we don't mind that a class is
> global, if you know what I mean. You could always
> encapsulate all your global data in a class called
> State (with class variables and accessors for them).
> 
> Then you could pretend to be doing something clever
> when actually you're just using one big fancy global
> variable. :)

Ok, <stupid question> so how would you
access the state object in the code below without
making it a global as I did?  </stupid question>

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


-- 
Jim Freeze
----------
You cannot propel yourself forward by patting yourself on the back.