From: Calvin Bornhofen Date: 2012-09-22T00:16:53+09:00 Subject: Re: Class variables > How about: > > class Foo > def self.suits > @suits ||= %w(C D H S) > end > end > Works too. If you just wanted to read the variable or perform actions with it, that is definitely shorter. > or even just > > class Foo > def self.suits > %w(C D H S) > end > end Looks similar, but it has one flaw: The array is created every time again the method is called ( checked via object_id - it differs every time the method is called ). Might not make a difference in this scenario, but if you wanted to modify the array, your changes wouldn't persist. So that's something to be aware of. It can also be a performance problem if the array gets more complex, I think.