From: will Date: 2006-12-28T15:46:23+09:00 Subject: Re: newbie with a weird technical problem (@ least I think it's weird) ------=_Part_115362_19174549.1167288380009 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Thanks All!!! Special thanks out to Morton and Phrogz for the extra, very handy, tips!! On 12/27/06, Phrogz wrote: > > will wrote: > > book = Book.new("Ruby Tutorial", "Dave", 831) > > book.inspect > > Others have mentioned the need to output the value you are returning, > and have suggested: > puts book.inspect > as a way to see that information. I just wanted to add the suggestion > that the 'p' method: > p book > automatically calls #inspect on the object(s) passed, and then spits > them to stdout like puts does. (For comparison, the puts method calls > #to_s on the object(s) passed.) 'p' is very convenient when developing > and testing out your application, as the output sometimes gives you > more insight into the actual format of the data...particularly for > arrays: > > irb(main):001:0> a = [ 1, '2', [ '3 4', 5 ], 6 ] > => [1, "2", ["3 4", 5], 6] > > irb(main):002:0> puts a > 1 > 2 > 3 4 > 5 > 6 > => nil > > irb(main):003:0> p a > [1, "2", ["3 4", 5], 6] > => nil > > As you can see from that first line, it's the result of #inspect that > irb uses when outputting the result of the last command. (Both puts and > p return nil when finished, which is where those two "=> nil" lines > come from in irb.) > > > -- watch it - http://www.videobomb.com/posts/show/7091 sign it - http://action.freepress.net/campaign/savethenet save it - http://savetheinternet.com/ ------=_Part_115362_19174549.1167288380009--