Re: Anything in D to avoid check for null everywhere?

2021-01-14 Thread ddcovery via Digitalmars-d-learn
On Thursday, 14 January 2021 at 21:49:41 UTC, Christian Köstlin wrote: ... Did you have a look at https://code.dlang.org/packages/optional? Especially https://aliak00.github.io/optional/optional/oc/oc.html might go in the right direction. Kind regards, Christian Thats nice!!! I was commen

Re: Anything in D to avoid check for null everywhere?

2021-01-14 Thread Christian Köstlin via Digitalmars-d-learn
On 12.01.21 22:37, Jack wrote: I was looking for a way to avoid null checks everywhere. I was checking the Null object pattern, or use something like enforce pattern, or even if I could make a new operator and implement something like C#'s .? operator, that Java was going to have one but they r

Re: Anything in D to avoid check for null everywhere?

2021-01-13 Thread ddcovery via Digitalmars-d-learn
On Tuesday, 12 January 2021 at 21:37:11 UTC, Jack wrote: I was looking for a way to avoid null checks everywhere. I was checking the Null object pattern, or use something like enforce pattern, or even if I could make a new operator and implement something like C#'s .? operator, that Java was go

Re: Anything in D to avoid check for null everywhere?

2021-01-13 Thread ddcovery via Digitalmars-d-learn
On Wednesday, 13 January 2021 at 09:02:37 UTC, ddcovery wrote: Find more details here: https://run.dlang.io/gist/392c06e745d1a35df71084ce4d29fed7 Ups... it seems that the link is not working (it is the first time I try to generate a dalng/gist link... I'm not sure if this can really be done)

Re: Anything in D to avoid check for null everywhere?

2021-01-13 Thread ddcovery via Digitalmars-d-learn
On Tuesday, 12 January 2021 at 21:37:11 UTC, Jack wrote: I was looking for a way to avoid null checks everywhere. I was checking the Null object pattern, or use something like enforce pattern, or even if I could make a new operator and implement something like C#'s .? operator, that Java was go

Re: Anything in D to avoid check for null everywhere?

2021-01-12 Thread Jack via Digitalmars-d-learn
Currently I'm with this: auto ref ifNotNull(T, T2)(T lhs, lazy T2 rhs) { if(lhs) { rhs(); } return lhs; } far from good. I wish there was a way to create a new operator so I would make .? similar to C#'s but would evaluate the left-handed side only if it's null and do noth

Anything in D to avoid check for null everywhere?

2021-01-12 Thread Jack via Digitalmars-d-learn
I was looking for a way to avoid null checks everywhere. I was checking the Null object pattern, or use something like enforce pattern, or even if I could make a new operator and implement something like C#'s .? operator, that Java was going to have one but they refused[1] (doesn't behave exact