Do you think if statement as expression would be nice to have in D?

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Sat Jun 4 04:54:43 UTC 2022


On Saturday, 4 June 2022 at 00:44:30 UTC, z wrote:
> why urgently? AFAIU pattern matching is equivalent to a bunch 
> of `if(value1 == *specialvalue or enum*) *insert statement(s) 
> here*;`

Yes, it makes most sense if you can do nested matching.

  add(mul(_,0),$x) => $x;
  add(mul($x,1),$y) => add($x,$y);
  add(mul($x,$y),$z) => muladd($x,$y,$z);



More information about the Digitalmars-d mailing list