therealadam (owner)

Revisions

gist: 7367 Download_button fork
public
Description:
'with' keyword for Ruby, if that's your thing
Public Clone URL: git://gist.github.com/7367.git
Embed All Files: show embed
with.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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