This question already has an answer here:
- What does @@variable mean in Ruby? 5 answers
I just started learning Ruby and I have been unable to find a good explanation on what is the difference between @@ and @ in terms of class variables. If anyone can provide a basic intuitive example, that would be really great. Also are they interchangeable?
A variable prefixed with
@@ is a class variable and one prefixed with
@ is an instance variable. A great description can be found in this answer: https://stackoverflow.com/a/5890199/1181886