title: undefined method `-' for nil:NilClass (NoMethodError)
body: <p>I can't work out how to fix it so it takes ten away from the health class variable, as it says that it is an error.</p>
  
  <pre><code>/home/will/Code/Rubygame/objects.rb:61:in `attacked': undefined method `-' for nil:NilClass (NoMethodError)
      from ./main.rb:140:in `update'
      from /var/lib/gems/2.3.0/gems/gosu-0.10.8/lib/gosu/patches.rb:140:in `tick'
      from /var/lib/gems/2.3.0/gems/gosu-0.10.8/lib/gosu/patches.rb:140:in `tick'
      from ./main.rb:197:in `&lt;main&gt;'
  </code></pre>
  
  <p>Here is the code in main:</p>
  
  <pre><code>def update
      @player.left if Gosu::button_down? Gosu::KbA
      @player.right if Gosu::button_down? Gosu::KbD
      @player.up if Gosu::button_down? Gosu::KbW
      @player.down if Gosu::button_down? Gosu::KbS
      if Gosu::button_down? Gosu::KbK 
          @player.shot if @player_type == "Archer" or @player_type == "Mage"
          if @object.collision(@xshot, @yshot) == true
              x, y, health = YAML.load_file("Storage/info.yml")
              @object.attacked #LINE 140
          end
      end
  
  end
  </code></pre>
  
  <p>And here is where the @object.attacked leads to:</p>
  
  <pre><code> def attacked
      puts "attacked"
      @health -= 10 #LINE 61
      @xy.insert(@health)
      File.open("Storage/info.yml", "w") {|f| f.write(@xy.to_yaml) }
      @xy.delete_at(2)
      if @health == 0
          @dead = true
      end
  end 
  </code></pre>
  
  <p>And the yaml file if needed:</p>
  
  <pre><code>   ---
     - 219.0
     - 45.0
     - 100.0
  </code></pre>
  
  <p>I tried to put .to_i after the @health like this:</p>
  
  <pre><code>   @health.to_i -= 10
  </code></pre>
  
  <p>But it just brings up another error saying:</p>
  
  <pre><code>   undefined method `to_i=' for nil:NilClass (NoMethodError)
  </code></pre>