How do you change what is printed with puts
when an object is referenced?
Consiser the following code:
class MyClass
attr_accessor :var
def initialize(var)
@var = var
end
# ...
end
obj = MyClass.new("content")
puts obj # Prints #<MyClass:0x0000011fce07b4a0> but I want it to print "content"
I imagine that there is an operator that you can overload (or something similar), but I don't know what it's called so I have no clue what to search for to find the answer.