DEV Community

austinmei5
austinmei5

Posted on

Attr Accessor

attr_accessor :color

  • Creates a set of 'set' and 'get' methods for 'color'

attr_reader :color

  • Creates a 'get' method for 'color'

attr_writer :color

  • Creates a 'set' method for 'color'

def initialize(color)
@color = color
end

  • initializes a variable that cannot be changed later when creating an instance of an object

Top comments (0)