25 lines
336 B
Ruby
Executable File
25 lines
336 B
Ruby
Executable File
#!/usr/bin/ruby
|
|
# -*- coding: utf-8 -*-
|
|
|
|
=begin
|
|
여러 Person 객체를 배열로 관리
|
|
=end
|
|
|
|
class Person
|
|
attr_accessor :name, :age
|
|
|
|
def initialize(name, age)
|
|
@name = name
|
|
@age = age
|
|
end
|
|
|
|
def grow_up
|
|
@age += 1
|
|
end
|
|
end
|
|
|
|
people = [
|
|
Person.new("Charlie", 13),
|
|
Person.new("Steve", 48),
|
|
Person.new("Anne", 34)
|
|
] |