07-18-2023, 01:38 PM
Ruby has this handy and convenient way to share instance variables by using keys like
attr_accessor :var
attr_reader :var
attr_writer :var
Why would I choose `attr_reader` or `attr_writer` if I could simply use `attr_accessor`? Is there something like performance (which I doubt)? I guess there is a reason, otherwise they wouldn't have made such keys.
attr_accessor :var
attr_reader :var
attr_writer :var
Why would I choose `attr_reader` or `attr_writer` if I could simply use `attr_accessor`? Is there something like performance (which I doubt)? I guess there is a reason, otherwise they wouldn't have made such keys.