Ruby Examples
This commit is contained in:
24
level7/67.rb
Executable file
24
level7/67.rb
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/ruby
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
=begin
|
||||
클래스 메서드 작성
|
||||
=end
|
||||
|
||||
class Person
|
||||
attr_accessor :name, :age
|
||||
|
||||
def initialize(name, age)
|
||||
@name = name
|
||||
@age = age
|
||||
end
|
||||
|
||||
def self.species
|
||||
"Homo Sapiens"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
puts Person.species
|
||||
charlie = Person.new("Charlie", 13)
|
||||
puts charlie.class.species
|
||||
Reference in New Issue
Block a user