From: itsme213@... (you CAN teach an old dog ...) Date: 2003-06-13T08:26:04+09:00 Subject: Confused about to_s in Ruby / irb I wish to control the default display of my objects, and thought to_s would be the right hook. But ruby (at least irb) seems to use my to_s only if the class has no instance variables. Am I doing something wrong? What other display-related hooks are there? Thanks irb> class A irb> def to_s irb> "an A" irb> end irb> end nil irb> A.new an A # uses to_s irb> class B irb> def initialize(x) irb> @x = x irb> end irb> def to_s irb> "a B" irb> end irb> end nil irb> B.new (5) # # ignores to_s