P vs. print

No problem. I actually used to think that they were identical, which led to
some confusion. That's the only reason i point it out.

···

On Thu, Sep 2, 2010 at 3:58 PM, Alex Stahl <astahl@hi5.com> wrote:

Sorry, my wording was off. Understood that they're different methods.

I think of them synonymously, and so when I say "short for", I mean
that's my way of thinking about how they accomplish similar tasks, not
that "p" is literally a representation of "puts".

Thanks for the clarification in any case.

On Thu, 2010-09-02 at 14:46 -0500, Colin Bartlett wrote:
> On Thu, Sep 2, 2010 at 8:40 PM, Quintus <sutniuq@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"

Thanks everyone for the clarification.

@Andrew. When you say: "...it's just a regular ol' method on Object.".

What do you mean by "ol'"?

Thanks.

···

--
Posted via http://www.ruby-forum.com/.

Not to mention pp which is prettyprint
http://ruby-doc.org/stdlib/libdoc/pp/rdoc/index.html
And there is ap which is awesomeprint http://github.com/michaeldv/awesome_print

MarkT

···

--
(+61 4) 0679 5734 :: skype: govirtual.com.au :: チェックアウトが、Jingle だ!
::It's a Jingle Out There!

Mark T wrote:

Not to mention pp which is prettyprint
http://ruby-doc.org/stdlib/libdoc/pp/rdoc/index.html
And there is ap which is awesomeprint
GitHub - michaeldv/awesome_print

MarkT

That's nice.

···

--
Posted via http://www.ruby-forum.com/\.