If you call a method that doesn’t exist, Ruby calls method_missing
.
You can override it to handle undefined methods.
class MyClass
def method_missing(name, *args)
puts "Method #{name} is missing!"
end
end
obj = MyClass.new
obj.hello #
If you call a method that doesn’t exist, Ruby calls method_missing
.
You can override it to handle undefined methods.
class MyClass
def method_missing(name, *args)
puts "Method #{name} is missing!"
end
end
obj = MyClass.new
obj.hello #
Leave a Reply