From: Charles Steinman Date: 2005-08-16T23:01:13+09:00 Subject: Re: newbie, to_s question EdUarDo wrote: > def to_s > puts "#@name" > end > end > > > I do: > > tactic = Tactic.new > tactic.loadDefaultTactic > puts tactic > > and get: > > 4-4-2 > # > > > Why do I get the internal representation of Tactic? > > Why is not the response '4-4-2' only? You are not returning "4-4-2" in to_s. You are directly printing "4-4-2" with puts in the to_s method. The return value of puts is nil. So to_s is printing "4-4-2" and then returning nil. And when to_s returns nil, puts will instead use inspect to get a string for output. So the second puts prints tactic.inspect. You want your to_s method to look something like this: def to_s @name.to_s end