W
Walle Wallen
Long story short. I'm trying to overload the normal behavior of an
object/instance in a string. Instead of replying "<Test:0x101121db0>" I
would like it too return a specific string, or something similar. I have
tried to overload inspect, and it seems to work pretty well, except when
using the object with puts or in a string "#{p}".
My english ain't good, but I hope you understand the principle of what I
am trying to achieve.
object/instance in a string. Instead of replying "<Test:0x101121db0>" I
would like it too return a specific string, or something similar. I have
tried to overload inspect, and it seems to work pretty well, except when
using the object with puts or in a string "#{p}".
My english ain't good, but I hope you understand the principle of what I
am trying to achieve.
Code:
class Test
def inspect
puts "this is a test"
end
end
p = Test.new
this is a testthis is a test
puts p
=> "#<Hejsan:0x1010fd7f8>"