# Class names must be capitalized. Technically, it's a constant. class Fred # The initialize method is the constructor. The @val is # an object value. def initialize(v) @val = v end # Set it and get it. def set(v) @val = v end def to_s return "Fred(val=" + @val.to_s + ")" end # Since a simple access function is so common, ruby lets you declare one # automatically, like this: attr_reader :val # You can list any number of object variables. Separate by commas, and each # needs its own colon # attr_reader :fred, :joe, :alex, :sally end class Alice