Skip to content

Instantly share code, notes, and snippets.

@mikewadhera
Created May 4, 2010 07:08
Show Gist options
  • Save mikewadhera/389072 to your computer and use it in GitHub Desktop.
Save mikewadhera/389072 to your computer and use it in GitHub Desktop.
thunk.rb
class Thunk
def initialize(&block)
@block = block
end
def method_missing(m, *args, &block)
result = @block.call
define_method(m) { result }
end
end
thunk = Thunk.new { Time.now }
thunk.get
thunk.get
thunk.get
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment