Associative Array, get value instead of poiter using `if (auto ..)`, possible?

ryuukk_ ryuukk.dev at gmail.com
Sat Aug 31 15:38:49 UTC 2024


Let's see how other languages do it:

```zig
     map.put("hello", 42);

     // get pointer
     if (map.get("hello")) |*it| {
         std.log.debug("{}", .{it});
     }

     // get value
     if (map.get("hello")) |it| {
         std.log.debug("{}", .{it});
     }
```

No imports, no templates, ONE LINER

Please submit PRs to DMD, not phobos


More information about the Digitalmars-d-learn mailing list