0
0

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 5 years have passed since last update.

【Ruby】変数を文字列に入れ込む

Posted at

変数に文字列を入れ込む

Ruby初心者のメモ書きです。

qiita.rb
name = "田中"
name2 = "斎藤"
puts "こんにちは、#{name}さん!"
puts 'こんにちは、#{name2}さん!'
#結果
こんにちは、田中さん!
こんにちは、#{name}さん!

シングルクオートで囲むと、変数は展開されずにそのまま出力される!!

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?