title: Instance variable becomes undefined - CoffeeScript
body: <pre><code>class Game
  
    foo: null
  
    play: -&gt;
  
      @foo = 2
      @animate()
  
    animate: -&gt;
  
      requestAnimationFrame( @animate, 1000 )
      console.log('foo = ', @foo)
  
  
  $ -&gt;
    game = null
  
    init = -&gt;
  
      game = new Game()
      game.play()
  
    init()
  </code></pre>
  
  <p>The log in the animate method in Game produces:</p>
  
  <p>foo = 2</p>
  
  <p>foo = undefined </p>
  
  <p>So foo is 2 on the first call to animate and then undefined thereafter. Could someone please explain why and how I can fix this. Any help is much appreciated.</p>