String interpolation (included): Difference between revisions

Content added Content deleted
(PascalABC.NET)
Line 1,452: Line 1,452:
All interpolations in langur use double curly braces.
All interpolations in langur use double curly braces.


<syntaxhighlight lang="langur">val .x = "little"
<syntaxhighlight lang="langur">val x = "little"
writeln "Mary had a {{.x}} lamb."</syntaxhighlight>
writeln "Mary had a {{x}} lamb."</syntaxhighlight>


Modifiers follow the interpolated value with a colon.
Modifiers follow the interpolated value with a colon.
<syntaxhighlight lang="langur">writeln "Lamb count: {{.x : 7}}"</syntaxhighlight>
<syntaxhighlight lang="langur">writeln "Lamb count: {{x : 7}}"</syntaxhighlight>


Modifiers may be chained within a single interpolation.
Modifiers may be chained within a single interpolation.
<syntaxhighlight lang="langur">writeln "Partial lamb count: {{.x : r2 : 10}}"
<syntaxhighlight lang="langur">writeln "Partial lamb count: {{x : r2 : 10}}"
# rounds to 2 decimal places, then aligns to 10 code points
# rounds to 2 decimal places, then aligns to 10 code points
# (hopefully no partial lambs)
# (hopefully no partial lambs)