From: "Carina C. Zona" Date: 2011-10-07T07:10:17+09:00 Subject: Re: Simply question On Thu, Oct 6, 2011 at 2:02 PM, Sam Duncan wrote: > On 07/10/11 09:56, itankgo itankgo wrote: >> >> Can't understand: >> >> # coding: cp1251 >> >> x = puts 'bbb' >> puts x >> >> out needs to be: >> >> =>  bbb >> =>  nil >> >> But nil is not returned(bbb displayed),only empty line instead of nil is >> on screen. >> >> ruby v.1.9.2-p180 >> > Try > > x = puts 'bbb' > > puts x.inspect The docs for IO#print, IO#puts, and OI#inspect help understand what's going on here. puts outputs myobject.to_s followed by an added newline. x is nil, the string representation of nil is '', so puts x correctly outputs "\n". As Sam noted, the inspect method is what's needed for these situations. --   Carina