return val if

Mike Parker aldacron at gmail.com
Sun Mar 22 19:07:17 UTC 2020


On Sunday, 22 March 2020 at 19:04:40 UTC, Mike Parker wrote:

>
> ```
> T returnValIfFail(T)(bool expr, T val) {
>     if(expr) return val;
>     else assert(0);
> }

> ```

Heh, of course, as Dennis pointed out, that's essentialy 
assert(expr).

```
assert(expr);
x = val;
```


More information about the Digitalmars-d-learn mailing list