Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is difference between "p" and "pp"?

Tags:

ruby

I did do some searching, but can't find an answer to simple question.

What is difference between p and pp in Ruby? I know you need to require 'pp'. Besides that what are the differences?

like image 984
slindsey3000 Avatar asked Jan 25 '12 19:01

slindsey3000


People also ask

What is P and PP in APA?

Short quotations If you are directly quoting from a work, you will need to include the author, year of publication, and page number for the reference (preceded by "p." for a single page and “pp.” for a span of multiple pages, with the page numbers separated by an en dash).

Is one page P or PP?

If you're referring to only one page, use the abbreviation p. and if there are multiple pages, use pp. This is how you can abbreviate the word page and pages.

What does pp mean in MLA?

P for Press (used for academic presses) p. for page, pp. for pages.

Why are pages called PP?

Abbreviation of pages. (plural of p.) Abbreviation of past participle.


1 Answers

p is used to inspect a variable as a debug aide. It works printing the output of the method #inspect. For example p foo will output the content of foo.inspect.

Sometimes you need to debug complex variables or nested variables. In this case p will output a long line that is hard to understand. Instead, pp will put try to arrange the content of the variable so that it is easier to understand, for example indenting nested arrays or using one line for each instance variable of a complex object. pp does this calling the #pretty_inspect method (the pp library adds #pretty_inspect methods to many classes such as String, Array or Struct).

To remember: p = print, pp = pretty print.

like image 199
gioele Avatar answered Oct 11 '22 11:10

gioele