Neither to_s nor to_str appear to be called when the object is referenced inside to_str string interpolation. For instance:
# UPDATE: This example actually works as expected. See update below. class Foo def to_s 'foo' end def to_str to_s end end "#{Foo.new}" # result: "#<Foo:0x007fb115c512a0>"
I donβt think what I can do to make the return value "foo" ?
UPDATE
Sorry, but this code really works. Error in another piece of code.
source share