digitalmars.D.learn - Multiply a string?
- Andy Valencia (9/9) Jun 07 In logging output, I often want indentation. In Python, the
- Sergey (10/14) Jun 07 I think there are many ways to do it
- Andy Valencia (4/6) Jun 07 Thanks! repeat() it is (though I just wrote on which avoids the
In logging output, I often want indentation. In Python, the output is built like: ``` print(" " * ddepth, "data at this level: ", datum) ``` Which is to say, build a string by concatenating " " ddepth times. Is there a comparable idiom in dlang or Phobos? Thanks! Andy
Jun 07
On Saturday, 7 June 2025 at 16:13:06 UTC, Andy Valencia wrote:Which is to say, build a string by concatenating " " ddepth times. Is there a comparable idiom in dlang or Phobos? Thanks! AndyI think there are many ways to do it The simplest that comes to my mind: ```d void main() { string error_message = "D's desing is far from perfect"; writeln(" ".repeat(5).join, "[INFO]:", Clock.currTime(), " - ", error_message); } ```
Jun 07
On Saturday, 7 June 2025 at 16:42:51 UTC, Sergey wrote:I think there are many ways to do it The simplest that comes to my mind:Thanks! repeat() it is (though I just wrote on which avoids the interim representation, so no join() needed). Andy
Jun 07