On Wednesday, 12 April 2023 at 13:09:07 UTC, Ali Çehreli wrote:
Not every type is null'able but nullable. ;) So, a design may
use the following:
https://dlang.org/library/std/typecons/nullable.html
I implemented Handler into the Voldermort build, which Walter
loved so much. For convenience,
On 4/12/23 04:35, Salih Dincer wrote:
> I made a little mistake and I'll fix it before someone rub nose in it :)
You asked for it! :)
>auto opIndex(string key) {
> if(auto ret = key in data)
> {
>return *ret;
> }
> return null;
>}
Not every type is
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) {
On Wednesday, 12 April 2023 at 01:16:17 UTC, Chris Katko wrote:
Should I be using opEquals? Or something different? The problem
with 'alias this' here is I want to wrap access to the insides
with getter functions that do various things like logging and
error checking.
I think you want to do
You want the operator overload opIndex inside your class.
https://dlang.org/spec/operatoroverloading.html#array
```D
class bitmapHandler
{
bitmap*[string] bmps;
void get(string name){return bmps[name]; /* plus other code */}
}
void usage()
{
bitmapHandler bh;
bitmap foo = bh.get("bar"); // works
bitmap foo2 = bh["bar"]; // desired
}
```
Should I be using opEquals? Or something different? The problem