On Wednesday, 12 April 2023 at 04:57:58 UTC, Salih Dincer wrote:
I think you want to do an encapsulation like below.

```d
  auto opIndex(string key)
    => *(key in data);
```

I made a little mistake and I'll fix it before someone rub nose in it :)

```d
  auto opIndex(string key) {
    if(auto ret = key in data)
    {
      return *ret;
    }
    return null;
  }

  assert(handler["D Lang"] == &foo);
  assert(handler["null"] is null);
```

SDB@79


  • Assocative array... Chris Katko via Digitalmars-d-learn
    • Re: Assocat... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
    • Re: Assocat... Salih Dincer via Digitalmars-d-learn
      • Re: Ass... Salih Dincer via Digitalmars-d-learn
        • Re:... Ali Çehreli via Digitalmars-d-learn
          • ... Salih Dincer via Digitalmars-d-learn

Reply via email to