Skip to content

Instantly share code, notes, and snippets.

@divoxx
Created March 25, 2014 20:13
Show Gist options
  • Select an option

  • Save divoxx/9770355 to your computer and use it in GitHub Desktop.

Select an option

Save divoxx/9770355 to your computer and use it in GitHub Desktop.
class Foo
def self.bar
return @bar if defined?(@bar)
puts "Calculating"
@bar = "bar"
end
end
irb(main):008:0> Foo.bar
Calculating
=> "bar"
irb(main):009:0> Foo.bar
=> "bar"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment