Created
August 7, 2013 15:17
-
-
Save arr-ee/6175003 to your computer and use it in GitHub Desktop.
Making an object to behave like string
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 A; | |
def initialize a | |
@a = a | |
end | |
def to_str | |
@a.dup | |
end | |
def == o | |
@a == o | |
end | |
end | |
'a' == A.new('a') | |
#=> true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment