I've read this thread When do Ruby instance variables get set? but i'm in two minds when to use class instance variables.
Class variables are shared by all objects of a class, Instance variables belong to one object... Not much room left to use class instance variables if we have class variables...
Could you explain to me difference between these two and when to use them?
code example:
class S
@@k = 23
@s = 15
def self.s
@s
end
def self.k
@@k
end
end
p S.s #15
p S.k #23
Update
I understand now, Class Instance Variables are save from being passed on inheritance chain! Thanks to all!