Skip to content

Instantly share code, notes, and snippets.

@patmaddox
Created April 1, 2011 10:02
Show Gist options
  • Save patmaddox/897965 to your computer and use it in GitHub Desktop.
Save patmaddox/897965 to your computer and use it in GitHub Desktop.
lazy ivar initialization?
class SomethingDoer
def initialize
lazy_init(:foo) { Foo.new }
end
def do_something
@foo.something # doesn't blow up because it auto-init'd
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment