reduce condition nesting
Temtaime
temtaime at gmail.com
Thu Nov 23 17:38:18 UTC 2017
On Thursday, 23 November 2017 at 14:16:25 UTC, Andrea Fontana
wrote:
> On Thursday, 23 November 2017 at 13:47:37 UTC, Adam D. Ruppe
> wrote:
>> On Thursday, 23 November 2017 at 05:19:27 UTC, Andrey wrote:
>>> for instance in kotlin it can be replace with this:
>>>> when {
>>>> c1 -> foo(),
>>>> c2 -> bar(),
>>>> c3 -> ...
>>>> else -> someDefault()
>>>> }
>>
>> The `switch` statement covers some of these cases too.
>
> Anyway you can create something like this:
> https://run.dlang.io/is/7pbVXT
Syntax #4
// Syntax #4
when
(
c1, { writeln("first"); },
c2, { writeln("second"); },
{ writeln("default"); }
);
:)
More information about the Digitalmars-d-learn
mailing list