Readable attribute and writable attribute
class Employee
attr_reader :name
attr_accessor :title, :salary
def initialize( name, title, salary )
@name = name
@title = title
@salary = salary
end
end
fred = Employee.new("Fred", "Operator", 30000.0)
fred.salary=35000.0
Related examples in the same category