I am trying to run a simple program:
class Pras
def samleMethod
a = 12
p "a"
end
end
There are no errors, but why is not output being shown?
Edit
class Pras
def samleMethod
a = 12
p a
end
end
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.
In this you are creating a class named Pras with public method named sampleMethod.
I assume you have some knowledge with OOP
so when ever you are accessing a a method you need to create an instance of class to access it.
Now you can access the method using the instance
or both in one line as
I would suggest you to have a through look at this tuts. http://www.tutorialspoint.com/ruby/ruby_quick_guide.htm
methods will not be executed unless they are called.
Try this code online here