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

ryuukk_ ryuukk.dev at gmail.com
Sat Aug 31 16:44:04 UTC 2024


On Saturday, 31 August 2024 at 16:34:00 UTC, Lance Bachmeier 
wrote:
> On Saturday, 31 August 2024 at 15:38:49 UTC, ryuukk_ wrote:
>> 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
>
> It's good you're not in charge here because that is hideous.

Paul Backup solution is infinity better, i apologies

I'll now leave, just like everyone else, sorry for the noise, who 
am i to expect improvements, i should have known better


More information about the Digitalmars-d-learn mailing list