| Store | Cart

Re: p vs. print

From: Colin Bartlett <coli...@googlemail.com>
Fri, 3 Sep 2010 04:46:59 +0900
On Thu, Sep 2, 2010 at 8:40 PM, Quintus <sutn...@gmx.net> wrote:

> Am 02.09.2010 21:23, schrieb Alex Stahl:> > Ruby uses "puts", not "print".  "p" is short for "puts".> > Try this:> > puts ary1> > You'll get the same results as:> > p ary1>>
This is definitely wrong. #p is quite another method than #puts and yet
>  another than #print. Look at this ...

 And as another example of the differences:
class P
  def inspect(); "P#inspect"; end
  def to_s(); "P#to_s"; end
end

q = P.new
puts "p"
p q         #=> "P#inspect"
puts "puts"
puts q     #=> "P#to_s"
puts "print"
print q
puts ":: just after print"
              #=> "P#to_s:: just after print"

Recent Messages in this Thread
Abder-Rahman Ali Sep 02, 2010 07:16 pm
Alex Stahl Sep 02, 2010 07:23 pm
Quintus Sep 02, 2010 07:40 pm
Andrew Wagner Sep 02, 2010 07:44 pm
Colin Bartlett Sep 02, 2010 07:46 pm
Alex Stahl Sep 02, 2010 07:58 pm
Andrew Wagner Sep 02, 2010 08:07 pm
Abder-Rahman Ali Sep 03, 2010 01:20 am
Mark T Sep 03, 2010 02:09 am
Abder-Rahman Ali Sep 03, 2010 11:05 am
Chad Perrin Sep 04, 2010 04:02 pm
Rob Biedenharn Sep 04, 2010 05:00 pm
Josh Cheek Sep 04, 2010 05:01 pm
Abder-Rahman Ali Sep 02, 2010 07:49 pm
Abder-Rahman Ali Sep 02, 2010 07:52 pm
Andrew Wagner Sep 02, 2010 07:56 pm
Abder-Rahman Ali Sep 03, 2010 12:26 pm
Brian Candler Sep 03, 2010 08:31 am
Edmond Kachale Sep 03, 2010 10:47 am
Abder-Rahman Ali Sep 03, 2010 10:54 am
Abder-Rahman Ali Sep 03, 2010 10:54 am
Brian Candler Sep 03, 2010 01:21 pm
Abder-Rahman Ali Sep 03, 2010 02:02 pm
Messages in this thread

Previous post: Re: p vs. print
Next post: Re: p vs. print