2
1

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.

【Swift】\()を使用せず、文字列と一緒に変数をコンソール出力する方法

Posted at

コンソールに文字列と一緒に変数を出力したい際、下記のように「 \ (変数)」を使用する方が多いと思います。


var foodList = ["カレー", "ラーメン", "カツ丼"]
print("食べ物: \(foodList)")
//出力結果 食べ物: ["カレー", "ラーメン", "カツ丼"]

実は下記のように、変数の前に「 , 」をつけるだけでもOKなんです。
「 \ ()」をタイプするよりも圧倒的に楽なのでオススメです。


print("食べ物: ", foodList)
//出力結果 食べ物: ["カレー", "ラーメン", "カツ丼"]
2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?