Skip to content

Instantly share code, notes, and snippets.

@therealadam
Created August 26, 2008 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save therealadam/7367 to your computer and use it in GitHub Desktop.
Save therealadam/7367 to your computer and use it in GitHub Desktop.
'with' keyword for Ruby, if that's your thing
module Kernel
def with(obj, &block)
obj.instance_eval(&block)
end
end
with 'Hi' do
length # => 2
upcase # => "HI"
downcase # => "hi"
foo = length
foo + 2 # => 4
Math.sin(1) # => 0.841470984807897
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment