[Haskell-beginners] Global variable question

Joe Van Dyk joe at fixieconsulting.com
Wed Dec 30 20:49:12 EST 2009


What's the appropriate way to write this in Haskell?

# Ruby code, ignore the thread-unsafety for now.
class Ticker
  @@tick = 0
  def self.update!
    @@tick += 1
  end
  def self.current
    return @@tick
   end
end

Ticker.update! # 1
Ticker.update! # 2
Ticker.current  # 2


-- 
Joe Van Dyk
http://fixieconsulting.com


More information about the Beginners mailing list