4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Ruby | 改行だけを出力する

4
Last updated at Posted at 2016-02-08

解決

引数を渡さずに puts すればOK。

puts

puts
puts 'Gumi'
puts
puts 'Chocolate'
puts
puts 'Pine'
puts

image

問題

たとえば、テキストの先頭に改行を付けたいことがある。
だが次のような書き方は野暮ったい。

puts "\nTEXT"
puts "\n"
puts "TEXT"

解は前述のとおり。

環境

  • Ruby 2.3.0

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

メンター受付

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?