p foo
prints foo.inspect
followed by a newline, i.e. it prints the value of inspect
instead of to_s
, which is more suitable for debugging (because you can e.g. tell the difference between 1
, "1"
and "2\b1"
, which you can’t when printing without inspect
).
More Related Contents:
- How to convert Time format in ruby
- Regex for reverse match a string
- Why do Ruby setters need “self.” qualification within the class?
- What is the difference between require_relative and require in Ruby?
- Why does Ruby 1.9.2 remove “.” from LOAD_PATH, and what’s the alternative?
- rvm installation not working: “RVM is not a function”
- Ruby array access 2 consecutive(chained) elements at a time
- When to use lambda, when to use Proc.new?
- How to find and return a duplicate value in array
- How to search file text for a pattern and replace it with a given value
- How to split (chunk) a Ruby array into parts of X elements? [duplicate]
- What does tilde-greater-than (~>) mean in Ruby gem dependencies? [duplicate]
- Create two-dimensional arrays and access sub-arrays in Ruby
- How to merge Ruby hashes
- What does
- Serving static files with Sinatra
- Nokogiri, open-uri, and Unicode Characters
- Ruby 1.9: how can I properly upcase & downcase multibyte strings?
- How can I clear the terminal in Ruby?
- Ruby ‘require’ error: cannot load such file
- Testing modules in RSpec
- Why do two strings separated by space concatenate in Ruby?
- What does the equal (‘=’) symbol do when put after the method name in a method definition?
- Why does “compass watch” say it cannot load sass/script/node (LoadError)?
- When to use `require`, `load` or `autoload` in Ruby?
- Natural Language Processing in Ruby [closed]
- How can I get the absolute URL when extracting links using Nokogiri?
- How to determine if a character is a Chinese character
- What does the unary question mark (?) operator do?
- Should I use alias or alias_method?