p vs puts in Ruby

ruby

Solution

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

Problem

Is there any difference between `p` and `puts` in Ruby?

Original source