Ruby - Modules and Mixins
What will happen if you run this Ruby code?
module Sample
def greet
"Hello"
end
end
puts Sample.greetmodule Sample
def greet
"Hello"
end
end
puts Sample.greetgreet is an instance method inside the module, not a module method.Sample.greet tries to call a module method, but greet is not defined as such, causing NoMethodError.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions