Just another example of missing string interpolation
kdevel
kdevel at vogtner.de
Fri Oct 13 12:04:18 UTC 2023
On Thursday, 12 October 2023 at 21:45:55 UTC, bachmeier wrote:
>> [...]
>> What if `s` is `"${a}"` and `subs` is `["a": "${b}", "b":
>> "x"]`?
>
> That's the reason it needs to be supported by the language.
The problem with your code is that it loops over the wrong list.
It should iterate over the variable occurrences in the string `s`.
Granted that the language does support interpolation (DIP 1027):
How would you implement your function
string interp(string s, string[string] subs)
in terms of that built-in interpolation?
More information about the Digitalmars-d
mailing list