I have the following code:
class BookPrice attr_accessor :price def initialize(price) @price = price end def price_in_cents Integer(price*100 +
Your below code
def price @price = price # <~~ method name you just defined with `def` keyword. end
Creates never stopable recursion,.
How can I make this code work the way it is without attr_accessor?
You need to write as
def price=(price) @price = price end def price @price end