Here is what I have so far, it is not working:
class Couple(o,t)
one = o
two = t
end
couple1 = Couple.new(10, "Ten")
p couple1.one
p couple1.two
Not sure why it’s not working?
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.
Defining a class doesn’t work like defining functions, you have to define functions on them that use the internal variables, and the the initializer that tells it what to do when calling .new
attr_accessor helps with the crud of setting up the functions and variables. The most simplest ways would be to use have a class like
To use the new function to
initializethe class with a few variables, you can define that function giving you a Class definition looking like