class X
end
class A
def get_it
puts @the_variable
end
end
class B
def init_it
@the_variable = X.new
a = A.new
end
end
In the above code I want methods of Class A to access the instance of X instantiated in B
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.
Try using
Object#instance_variable_set: