What is “p” in Ruby?

p() is a Kernel method

It writes obj.inspect to the standard output.

Because Object mixes in the Kernel module, the p() method is available everywhere.

It’s common, btw, to use it in poetry mode, meaning that the parens are dropped. The CSV snippet can be written like…

CSV.open 'data.csv', 'r' do |row|
  p row
end

It’s documented here with the rest of the Kernel module.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)