Skip to content

Instantly share code, notes, and snippets.

@banyan
Created September 27, 2012 16:58
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 banyan/3795108 to your computer and use it in GitHub Desktop.
Save banyan/3795108 to your computer and use it in GitHub Desktop.
ruby 2.0.0dev Refinements (Classbox)
# http://yehudakatz.com/2010/11/30/ruby-2-0-refinements-in-practice/
# http://www.rubyist.net/~matz/20060104.html
# http://www.rubyist.net/~matz/20101113.html
module Foo
refine String do
def to_s
"hello"
end
end
end
module Bar
using Foo
p "a".to_s
end
p "a".to_s
# => "hello"
# => "a"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment