0
0

More than 3 years have passed since last update.

【Ruby】ヒアドキュメントの初歩的なつかいかた

Last updated at Posted at 2020-01-23

簡単に備忘録。

1. ヒアドキュメントとは

ヒアドキュメントは「文字列をシェルスクリプトやプログラミングに埋め込むためのもの」
""無しや改行&空白なども書いた通りに適用できる(長い文などに有効)。

2. 使い方

通常


puts "りんご"
puts "バナナ"
puts "メロン"
puts "いちご"

#=> 
りんご
バナナ
メロン
いちご

ヒアドキュメントの場合


puts <<~EOS
りんご
バナナ
メロン
いちご
EOS

#=> 
りんご
バナナ
メロン
いちご

参考

【3分でわかる】Rubyでヒアドキュメント
ヒアドキュメントとは・基本の使い方(ruby)

0
0
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
0
0