Link Details

Link 32601 thumbnail
User 111696 avatar

By bloid
via infoq.com
Published: Jul 31 2007 / 07:26

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".
  • 12
  • 1
  • 1141
  • 367

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Voters For This Link (12)



Voters Against This Link (1)