# 代入. 文字列中の変数展開

# Bash

str="His name is $NAME."

区切り位置を明示する場合は {} で囲う

str="His id is ${NAME}_X"

# JavaScript

s = `value is ${value}`

# PHP

$s = "value is ${value}";

define は展開されないよ

$s = "His name is " . NAME . "."

# PowerShell

$s = "value is $value"

# Python

s = 'value is %s' % (value)

どれでも同様に動作

  • '
  • "
  • '''
  • """

(value) の部分は複数ある場合はカンマ区切り
1個の場合は () は省略可

# Ruby

s = "value is #{value}" # だったっけ (TODO)

# Swift

s = "value is \(value)"

# TypeScript

s = `value is ${value}`

[ 📩 ご意見 ]