"Hal E. Fulton" <hal9000 / hypermetrics.com> wrote > I guess you know about p and puts, right? > puts obj > will call obj.to_s, but > p obj > will call obj.inspect instead. Sounds reasonable, but it does not explain the behavior below. It seems (p x) calls x.inspect if it is defined; otherwise it calls x.to_s >class None; end ==> nil >p None.new ==> #<None:0x2ac6110> >puts None.new ==> #<None:0x2ac46a0> >class To_S; def to_s; "to_s "; end; end ==> nil >p To_S.new # how come? ==> to_s >puts To_S.new ==> to_s >class Inspect; def inspect; "inspect "; end; end ==> nil >p Inspect.new ==> inspect >puts Inspect.new ==> #<Inspect:0x2ad97a8> >class Both > def to_s; "Both: to_s "; end > def inspect; "Both: inspect "; end >end ==>nil >p Both.new ==> Both: inspect >puts Both.new ==> Both: to_s