title: Undefined method `+' for nil:NilClass (NoMethodError)
body: <p>I'm writing a simple class that is initialized with a variable called "cash" which is an integer.</p>
  
  <p>Below is the code. When I run this, I get the NoMethodError. I know I can easily fix this by referencing the local class variable with @cash, but a book I read on OOP recommend to almost never use the @, and instead set the attr and use simply 'cash'. I have set attr_accessor, but it doesn't work, and I'd like to understand why. Thanks</p>
  
  <pre><code>class Person
    attr_accessor :cash
  
    def initialize(cash)
      @cash = cash
    end
  
    def add_cash(amount)
      cash = cash + amount
    end
  end
  </code></pre>