Concatenation/joining strings together in a more readable way

mipri mipri at minimaltype.com
Mon Dec 30 14:56:59 UTC 2019


On Monday, 30 December 2019 at 10:23:14 UTC, Marcone wrote:
> On Monday, 30 December 2019 at 09:41:55 UTC, mipri wrote:

>> This leaks too much.
>>
>>   writeln("Helo {} {}".format("xx", "name")); // Helo xx name
>>   writeln("Helo {} {}".format("{}", "name")); // Helo name {}
>
> This function replace {} for arguments received. You just need 
> don't send {} as arguments.
> I tested native function format() in Python:
> print("Helo {} {}".format("{}", "name")) # Helo {} name
> Nothing wrong, working same way.

It doesn't work the same way. These are not the same:

   Helo name {}
   Helo {} name

Python's implementation doesn't get confused if your format()
arguments include a {}.


More information about the Digitalmars-d-learn mailing list