Manipulating variables without evaluating them
Dadoum
dadoum at protonmail.com
Mon May 8 12:37:36 UTC 2023
On Monday, 8 May 2023 at 12:01:35 UTC, ag0aep6g wrote:
> Instead of passing values, pass functions that return the
> values:
>
> ```d
> auto plist = plistDict!([
> 0: () => "zero".conversionFunction,
> 1: () => "one".conversionFunction,
> 2: () => "two".conversionFunction,
> ]);
> ```
>
> And in `plistDict`, call the functions:
>
> ```d
> static foreach (key, fun; AA)
> {
> dict[key] = fun();
> }
> ```
Thanks, I can get further now with this trick, but now it is
complaining that some are delegate and other are function pointer
because in the real situation this happens:
```d
auto two = "two";
auto plist = plistDict!([
0: () => "zero".conversionFunction,
1: () => "one".conversionFunction,
2: () => two.conversionFunction,
]);
```
More information about the Digitalmars-d
mailing list