LoginSignup
1
1

More than 1 year has passed since last update.

文字列への変数埋め込み

Last updated at Posted at 2022-11-25

C#

string word = "World";
string text = $"Hello, {word}!";

JavaScript

const word = "World";
const text = `Hello, ${word}!`;

PHP

$word = "World";
$text = "Hello, {$word}!"; // ${word} でもおk。但し、PHP 8.2以降では非推奨だとコメントで教えてもらいました。

Python

word = "World"
text = f"Hello, {word}!"

Ruby

word = "World"
text = "Hello, #{word}!"
1
1
2

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