Skip to content

Instantly share code, notes, and snippets.

@arr-ee
Created August 7, 2013 15:17
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 arr-ee/6175003 to your computer and use it in GitHub Desktop.
Save arr-ee/6175003 to your computer and use it in GitHub Desktop.
Making an object to behave like string
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