Created
January 27, 2015 08:43
-
-
Save achempion/013528bb2c215af28779 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
module MyStringThing | |
refine String do | |
def at(num) | |
self[num..num] | |
end | |
end | |
end | |
class A | |
using MyStringThing | |
def fifth(str) | |
str.at(4) | |
end | |
end | |
class B | |
def fifth(str) | |
str.at(4) | |
end | |
end | |
A.new.fifth("qwerty") | |
# => "t" | |
B.new.fifth("qwerty") | |
# NoMethodError: undefined method `at' for "qwerty":String |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment