Chapter3. 클래스, 객체, 변수
3.0 클래스, 객체 변수
class Book ... b1 = Book.new() p b1 puts b1class Book def initialize(isbn, price) @isbn = isbn @price = price end # Getter def isbn=(isbn) @isbn = isbn end def price=(price) @price = price end Setter def isbn isbn end def price price end endclass Book ... def price_in_cents=(cents) price = 1000 * cents end ... end
속성, 인스턴시 변수, 메써드
3.3 접근 제어
protected
3.4 변수
Last updated