Last active
December 10, 2015 22:59
-
-
Save leifg/4506637 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
[~]$ ruby refinements.rb | |
refinements.rb:2: warning: Refinements are experimental, and the behavior may change in future versions of Ruby! | |
refinements.rb:10:in `<class:MyTestClass>': undefined method `using' for MyTestClass:Class (NoMethodError) | |
from refinements.rb:9:in `<main>' |
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
module RefinementTest | |
refine Hash do | |
def super_duper | |
"Hello World" | |
end | |
end | |
end | |
class MyTestClass | |
using RefinementTest | |
def initialize | |
puts {}.super_duper | |
end | |
end | |
MyTestClass.new |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example for problem with refinements in Ruby 2.0 (see http://www.ruby-forum.com/topic/4409740)