Associative Array, get value instead of poiter using `if (auto ..)`, possible?
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Sun Sep 1 02:10:27 UTC 2024
On 01/09/2024 4:34 AM, 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.
Hey now, there is no need to get personal, ryuukk is evaluating out
ideas and there is nothing wrong with this.
More information about the Digitalmars-d-learn
mailing list