Skip to content

Instantly share code, notes, and snippets.

@thorn
Created January 12, 2013 12:59
#-*- encoding: utf-8 -*-
class Employee
attr_reader :name
attr_accessor :salary, :title
def initialize(name, title, salary)
@name = name
@title = title
@salary = salary
end
end
fred = Employee.new("Fred Flinstone", "Crane operator", 30000.0)
# Так как мы сделали attr_accessor к полю salary, можно написать
fred.salary = 35000.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment