Created
September 27, 2012 16:58
-
-
Save banyan/3795108 to your computer and use it in GitHub Desktop.
ruby 2.0.0dev Refinements (Classbox)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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