I have a class:
class Foo
def self.test
@test
end
def foo
@test = 1
bar
end
private
def bar
@test = 2
end
end
object = Foo.new.foo
Foo.test
# => nil
The only way I could get it to output '2' is by making @test a class variable. Is there any other way around using the instance variable and being able to display it with Foo.test?
Foo.testwhich is a class method has no access to instance variables.