I'm a bit stumped. See the method below add_one. When using the increment, +=the Ruby operator throws a NoMethodError. The verbal version is working fine.
private method `count=' called for
Why is this?
class Counter
attr_reader :count
def initialize
@count = 0
end
def increment
add_one
end
private
attr_writer :count
def add_one
self.count += 1
end
end
c = Counter.new
puts c.count
puts c.increment
source
share