Skip to content

Instantly share code, notes, and snippets.

@xavdid
Last active August 29, 2015 14:27
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 xavdid/f252caab4797d3a24222 to your computer and use it in GitHub Desktop.
Save xavdid/f252caab4797d3a24222 to your computer and use it in GitHub Desktop.
Proof of concept for ruby refinements
class Fixnum
def dance
puts "I'M THE BEST DANCER"
end
end
require_relative 'refinements'
using EXT
1.dance # => "I'm dancing!"
say_hi # => "I'M THE BEST DANCER"
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
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