A
aidy
Hi,
The below code accesses the value of an instance variable
class Object_References
attr_reader
bj_1,
bj_2
def initialize
@obj_1 = "Object_1"
@obj_2 = "Object_2"
end
end
ref = Object_References.new
puts ref.obj_1
puts ref.obj_2
But how can I access the same value in a subclass?
class Whatever < Object_References
#how can I access the above objects variables here
end
Thanks
Aidy
The below code accesses the value of an instance variable
class Object_References
attr_reader
def initialize
@obj_1 = "Object_1"
@obj_2 = "Object_2"
end
end
ref = Object_References.new
puts ref.obj_1
puts ref.obj_2
But how can I access the same value in a subclass?
class Whatever < Object_References
#how can I access the above objects variables here
end
Thanks
Aidy