Skip to content

Instantly share code, notes, and snippets.

@kronos
Created December 9, 2010 11:29
Show Gist options
  • Save kronos/734627 to your computer and use it in GitHub Desktop.
Save kronos/734627 to your computer and use it in GitHub Desktop.
class X < String
def to_s
"#{self}" # <-- to_s, to_s...
end
end
X.new('a').to_s
@kronos
Copy link
Author

kronos commented Dec 9, 2010

class Q < String
def to_s
'a'
end

def to_str
'b'
end
end
puts Q.new('zzz')

on both 1.9.2 and 1.8.7 output will be 'zzz'. on rubinius - 'a'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment