I'm trying to figure out what attr_accessor gives me access attr_accessor . From what I understand, it provides getter and setter methods. So attr_accessor :color it will create for me something like the following
def color @color end def color=(value) @color = value end
I do not understand why in the following code why I can not use color= in my initializer? (it ends up empty). Why do I need to use @color= or self.color= instead? Shouldn't color= call the setter method that was just created for me above?
class Bird attr_accessor :color def initialize(c="green") color = c
source share