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

monkyyy crazymonkyyy at gmail.com
Sat Jun 4 02:24:41 UTC 2022


On Saturday, 4 June 2022 at 00:44:30 UTC, z wrote:
> (but it's possible that i'm mistaken, i could not find an 
> example of HS pattern matching with more than one value to 
> match per case.)

```swift
let point = CGPoint(x: 7, y: 0)
switch (point.x, point.y) {
   case (0,0): print("On the origin!")
   case (0,_): print("x=0: on Y-axis!")
   case (_,0): print("y=0: on X-axis!")
   case (let x, let y) where x == y: print("On y=x")
   default: print("Quite a random point here.")
}
```
https://alisoftware.github.io/swift/pattern-matching/2016/03/30/pattern-matching-2/
this would be an example of what I expect


More information about the Digitalmars-d mailing list