Ruby : There difference between puts and `p` methods

Note: There is vast difference between `p` and `puts` though they might look behaving similarly. For normal string there seem no difference in behavior however when there comes multi-line string or string containing CR / LF characters then the difference is vivid.

p "first line\n second line>>  "first line\n second line" 
 
puts "first line\n second line>>  first line 
        second line

123

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s