@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 S. [email protected]
Reply-To: [email protected]
Date: Thu, 2 Sep 2010 14:23:57 -0500
To: ruby-talk ML [email protected]
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