In the following code, does each Item instance get its own individual
value for :a or does the
:a key get overwritten every time I instantiate a new Item?
Class Item
attr_accessor :a
def init(args{})
@amt = args[:a]
end
end
In the following code, does each Item instance get its own individual
value for :a or does the
:a key get overwritten every time I instantiate a new Item?
Class Item
attr_accessor :a
def init(args{})
@amt = args[:a]
end
end
attr_accessor method does something quite different than you may think
As it does create getter and setter to an instance variable, it does
mean it would be class-instance specific.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs