String interpolation
tired_eyes via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Nov 10 02:41:50 PST 2015
On Tuesday, 10 November 2015 at 10:33:30 UTC, Tobias Pankrath
wrote:
> On Tuesday, 10 November 2015 at 10:21:32 UTC, tired_eyes wrote:
>> Hi,
>> The only example of string interpolation I've found so far is
>> on Rosetta Code:
>>
>> void main() {
>> import std.stdio, std.string;
>>
>> "Mary had a %s lamb.".format("little").writeln;
>> "Mary had a %2$s %1$s lamb.".format("little",
>> "white").writeln;
>> }
>>
>> Is this a "proper" way of string interpolation in D? This
>> looks a little clumsy. Are there any better approaches? Quick
>> skimming through the docs didn't give anything.
>
> std.string.format and std.format are the standard options. What
> are you missing?
Ruby:
a = 1
b = 4
puts "The number #{a} is less than #{b}"
PHP:
$a = 1;
$b = 4;
echo "The number $a is less than $b";
D:
???
More information about the Digitalmars-d-learn
mailing list