Ruby Examples
This commit is contained in:
22
level7/62.rb
Executable file
22
level7/62.rb
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/ruby
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
=begin
|
||||
인스턴스 메서드 작성
|
||||
=end
|
||||
|
||||
class Person
|
||||
attr_accessor :name, :age
|
||||
|
||||
def initialize(name, age)
|
||||
@name = name
|
||||
@age = age
|
||||
end
|
||||
|
||||
def hello
|
||||
puts "Hello, I'm #{name}!"
|
||||
end
|
||||
end
|
||||
|
||||
charlie = Person.new("Charlie", 13)
|
||||
puts charlie.hello
|
||||
Reference in New Issue
Block a user