# simple auto accessor/mutator example class Point attr_accessor :x, :y def initialize( x, y ) @x = x @y = y end def to_s "(#{@x}, #{@y})" end end pt = Point.new( 10, 15 ) puts pt pt.x = 5 pt.y = 3 puts pt pt.x += 10 puts pt # another example class Person attr_reader :name attr_writer :age def initialize( name, age ) @name = name @age = age end def to_s "#{@name}: #{@age} years old" end end # this is legal user = Person.new( "bob", 21 ) puts user.name user.age = 15 puts user # this is not a legal statement user.name = "George"