collimarco collimarco - 2 years ago 149
Ruby Question

p vs puts in Ruby

Is there any difference between

in Ruby?

Answer Source

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).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download