lab19: init
This commit is contained in:
21
lab19/method-missing.rb
Normal file
21
lab19/method-missing.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
class Person
|
||||
attr_accessor :name
|
||||
def initialize(name)
|
||||
@name = name
|
||||
end
|
||||
|
||||
def make_introduction
|
||||
puts "Hi, my name is #{@name}. Nice to meet you."
|
||||
end
|
||||
|
||||
def method_missing(m)
|
||||
puts "Didn't understand #{m}"
|
||||
end
|
||||
end
|
||||
|
||||
alice = Person.new('Alice')
|
||||
|
||||
alice.make_introduction
|
||||
alice.foo
|
||||
|
||||
|
||||
Reference in New Issue
Block a user