From: "Savard, Joseph" Date: 2010-09-03T21:22:15+09:00 Subject: Re: p vs. print @Alex & @Ali The correct explanation is P is effectively puts x.inspect Notice in the script I sent Ali I used inspect I in the printing of ary1 when using puts. [-------------------------] require "rubygems" require "narray" ary1 = NArray.sfloat(3,4) puts "---puts ary1.inspect produces" puts ary1.inspect puts "---p ary1 produces" p ary1 puts "---puts ary1 produces" puts ary1 puts "---" [------------------------] produces: ---puts ary1.inspect produces NArray.sfloat(3,4): [ [ 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0 ] ] ---p ary1 produces NArray.sfloat(3,4): [ [ 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0 ] ] ---puts ary1 produces --- ________________________________ From: Alex Stahl Reply-To: Date: Thu, 2 Sep 2010 14:23:57 -0500 To: ruby-talk ML Subject: Re: p vs. print Ruby uses "puts", not "print". "p" is short for "puts". Try this: puts ary1 You'll get the same results as: p ary1 On Thu, 2010-09-02 at 14:16 -0500, Abder-Rahman Ali wrote: > I wrote the following scripts from section (2) here: > http://ruby.gfd-dennou.org/tutorial/gokuraku/index-e.html > > require "rubygems" # Not in the example > require "narray" > ary1 = NArray.sfloat(3,4) > > When I tried to display the result using > > print ary1 > > It did NOT show anything. > > While when I used: > > p ary1 > > I got the result displayed? > > Why is that? > > Thanks.