module Hints
module Designer
def message
"Hello, World!"
end
end
end
p Hints::Designer.message
Why this give me the following error…?
undefined method `message’ for Hints::Designer:Module (NoMethodError)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
What you need to do is define message as a class method (not as an instance method). Try:
If you want to use instance methods with a module, you must extend an object using the module and any given constraints (see http://ruby-doc.org/core/classes/Module.html).