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 {}.
Try this:
import std: Format = format;
string format(T...)(T text){return text[0].replace("{}",
"%s").Format(text[1..$]);}