Concatenation/joining strings together in a more readable way

Marcone marcone at email.com
Tue Dec 31 08:55:37 UTC 2019


On Monday, 30 December 2019 at 14:56:59 UTC, mipri wrote:
> 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 {}.

Can you get me a bether? Like writeln("Hello #{var}");


More information about the Digitalmars-d-learn mailing list