Associative Array, get value instead of poiter using `if (auto ..)`, possible?
Paul Backus
snarwin at gmail.com
Sun Sep 1 03:06:53 UTC 2024
On Saturday, 31 August 2024 at 22:06:26 UTC, kdevel wrote:
> Is that functionally different from
>
> ```
> void main()
> {
> import std.stdio;
>
> int[string] test = ["hello": 42];
>
> if (auto p = "hello" in test)
> {
> writeln("hello => ", *p);
> }
> }
> ```
It's essentially the same. I only suggested it because the
original question was about alternatives to pointers, and
`Nullable` isn't a pointer.
I suppose it goes to show that avoiding language features just
for the sake of it ("no pointers", "no templates", "no imports",
...) is unlikely to accomplish anything useful. :)
More information about the Digitalmars-d-learn
mailing list