Piers Cawley writes about a potential problem he discovered in a blog article about Lazily Initialized Attributes. This is aimed to allow for lazily initialized attributes of a class. In this case, the @content instance variable is initialized with [] when it's accessor method content is called, unless it has already been initialized. The ||= operator means "if the left hand variable is nil, set it to the right hand value, otherwise just return the left hand variable's value".
Add your comment