October 11, 2019 Re: How about `and` and `or` like in Python? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul Backus | On Thursday, 10 October 2019 at 18:01:36 UTC, Paul Backus wrote:
> On Tuesday, 1 October 2019 at 00:47:57 UTC, Murilo wrote:
>> In Python the && operator is `and` just like the || operator is `or`. How about giving D this option? People could choose to use either of those forms. I am suggesting you create the `and` and `or` keywords to represent && and ||, respectively. That should make the code more readable.
>
> bool and(bool a, lazy bool b) { return a && b; }
>
> if (cond1.and(cond2)) {
> // ...
> }
>
> Implementation of `or` is left as an exercise for the reader. :)
Thanks.
|
Copyright © 1999-2021 by the D Language Foundation