Ruby standard output

Overview

Regarding the standard output used in Ruby, the difference in behavior when written with "''" or "" "" is summarized.

p method

p 'foo', 'bar', 'baz'

#result
"foo"
"bar"
"baz"
p "foo", "bar", "baz"

#result
"foo"
"bar"
"baz"

puts method

puts('foo, bar, baz')

#result
foo, bar, baz
puts("foo, bar, baz")

#result
foo, bar, baz

print method

print('foo\nbar\nbaz')

#result
foo\nbar\nbaz
print("foo\nbar\nbaz")

#result
foo
bar
baz

Summary

Recommended Posts

Ruby standard output
Ruby input / output
[ruby] drill output
[ruby] drill output
[ruby] drill output
[ruby] drill output
[ruby] drill output
[ruby] drill output
[ruby] drill output
Ruby standard input
From terminal to Ruby (standard input / output)
Ruby calorie calculation output
Output triangle in Ruby
[Ruby] How to use standard output in conditional branching
Java standard log output sample
Ruby standard input and various methods
[Ruby on Rails] CSV output function
String output method memo in Ruby
Ruby learning 4
[Ruby] Array
Ruby basics
Ruby Review 2
Ruby addition
Refactoring Ruby
Ruby learning 3
2020/10/4 Morning output
Ruby print puts p printf output method
2020/10/4 noon output
Learning output ~ 11/3 ~
Ruby setting 2
Ruby problem ⑦
2020/10/5 Morning output
Ruby learning 2
[Ruby] Block
Refactoring Ruby
ruby calculator
Ruby learning 6
Ruby settings 1
[Java] Color the standard output to the terminal
Refactoring Ruby
Learning output
2020/10/3 Noon output
Ruby basics
Ruby memo
Ruby learning 1
Ruby Review 1
2020/10/3 Morning output
[Ruby] Module
Learning Ruby with AtCoder 12 How to use standard output properly (p / puts / print)
[Java] How to get and output standard input
[Ruby] Difference between puts and return, output and return value
[ruby] How to receive values from standard input?