Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

1 total

lazy initialized boolean ruby 1.8.6

// lazily initialize a boolean accessor (requires ruby > 1.8.6)

  def attr?
    @attr = true unless instance_variable_defined? :@attr
    @attr
  end
1 total