-1

I am currently trying to parse a file in ruby and I ran into this example in the open uri module documentation (http://ruby-doc.org/stdlib-1.9.3/libdoc/open-uri/rdoc/OpenURI.html):

open("http://www.ruby-lang.org/") {|f|
    f.each_line {|line| p line}
  }

Do you guys know what the variable p in "|line| p line" is?

Thanks.

user2129856
  • 31
  • 1
  • 6
  • 1
    It's not a variable, it's a method, which you can clearly see because it takes an argument and variables cannot take an argument, only methods can. – Jörg W Mittag Mar 09 '14 at 02:28

2 Answers2

0
p() → nil

For each object, directly writes obj.inspect followed by a newline to the program’s standard output.

That's method

vrybas
  • 1,719
  • 17
  • 12
0

It does the same than puts but calls inspect instead of to_s on the object.

spickermann
  • 100,941
  • 9
  • 101
  • 131