Last active
August 29, 2015 14:27
-
-
Save xavdid/f252caab4797d3a24222 to your computer and use it in GitHub Desktop.
Proof of concept for ruby refinements
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
class Fixnum | |
def dance | |
puts "I'M THE BEST DANCER" | |
end | |
end |
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
require_relative 'refinements' | |
using EXT | |
1.dance # => "I'm dancing!" | |
say_hi # => "I'M THE BEST DANCER" |
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 EXT | |
refine Fixnum do | |
def dance | |
puts "I'm dancing!" | |
end | |
end | |
end | |
# If this line is uncommented, everything works as intended | |
# using EXT | |
def say_hi | |
puts 1.dance | |
end |
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
require_relative 'refinements' | |
require_relative 'bad' | |
puts 1.dance # => "I'M THE BEST DANCER" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment