Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!

Idiom #302 String interpolation

Given the integer x = 8, assign to the string s the value "Our sun has 8 planets", where the number 8 was evaluated from x.

s = std::format("Our sun has {} planets", x);
var s = $"Our sun has {x} planets";
var s = "Our sun has $x planets";
s = "Our sun has #{x} planets"
  write (unit=s,fmt='(*(G0))') "Our sun has ",x," planets."
s := fmt.Sprintf("Our sun has %d planets", x)
let s = `Our sun has ${x} planets`;
String s = String.format("Our sun has %s planets", x);
val s = "Our sun has $x planets"
$s = "Our sun has {$x} planets";
uses SysUtils;
s := Format('Our sun has %d planets',[x]);
uses SysUtils;
s := 'Our sun has '+x.ToString+' planets';
uses SysUtils;
s := 'Our sun has '+IntToStr(x)+' planets';
$s = "Our sun has $x planets"
s = f'Our sun has {x} planets'
s = "Our sun has #{x} planets."
let s = format!("Our sun has {x} planets");
let s = format!("Our sun has {} planets", x);

New implementation...
< >
programming-idioms.org