[英]how do i access instance variable of one class into other class define in other file in ruby
I have one file named class1.rb this is structure 我有一个名为class1.rb的文件,这是结构
module Person
class Amit
def initialize
@a=10
end
end
end
another file named class2.rb 另一个名为class2.rb的文件
module Person
class Sumit < Amit
def aos
puts "#{@a}"
end
end
end
i am not able to acess variable @a
in Sumit
how do i do that?? 我无法在
Sumit
访问变量@a
,我该怎么做?
您可以在这里看看(将实例变量添加到类中的红宝石) 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.