Created
June 15, 2015 05:54
-
-
Save ohnishiakira/9c81cf19f6633142557b to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby | |
module StringRefine | |
refine String do | |
def refine_test | |
self.upcase | |
end | |
end | |
end | |
class Hoge | |
using StringRefine | |
def test | |
p 'hoge'.refine_test | |
#=> "HOGE" | |
p %w( hoge fuga ).map{|s| s.refine_test } | |
#=> ["HOGE", "FUGA"] | |
p %w( hoge fuga ).map(&:refine_test) | |
#-> NoMethodError | |
end | |
end | |
puts RUBY_VERSION | |
#=> 2.2.2 | |
Hoge.new.test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment