stri: string format/interpolation library for D. how to embed variables into string like shell scripts
Shigeki Karita
shigekikarita at gmail.com
Sun Jul 29 14:55:46 UTC 2018
This library is very similar to Scala or shell scripts.
- https://github.com/ShigekiKarita/stri/tree/master
-
https://docs.scala-lang.org/overviews/core/string-interpolation.html
## example
import stri : s;
// runtime/compile-time variables
auto a = 1;
enum _a0 = "D-lang";
struct A {
static a = 0.123;
}
// you can use the default %s and custom ones e.g., %.3f
mixin s!"${a} is one. ${_a0} is nice. ${A.a%.3f}" i;
assert(i.str == "1 is one. D-lang is nice. 0.123");
More information about the Digitalmars-d-announce
mailing list