I understand that when we define a class variable in ruby it's preceded with
@@variableName
but in this code
class Hello
@var2
@@var3=0
def foo1
return @var1
end
def set_foo1(par1)
@var1=par1
end
end
I understand that var3 is a class variable and has to be initialized with some value. But what about var2? Is var2 still corresponds to an object?
When i called the program with obj1.var2=100
i get a noMethodError
Also, when i call puts Hello.var3
i get the same noMethodError
Can anyone please explain where i am getting it wrong?