Discussion Thread: DIP 1043--Shortened Method Syntax--Final Review
welkam
wwwelkam at gmail.com
Tue Jun 28 13:38:59 UTC 2022
On Tuesday, 28 June 2022 at 11:25:53 UTC, WebFreak001 wrote:
> ```d
> int width() => shape.match!(
> (Box b) => b.width,
> (Circle c) => c.radius * 2
> );
> ```
Thank you for providing excellent example for an argument against
this DIP. To a person who haven't coded in D for a while it was
hard to understand what that code did. Also this is prime example
to all people who talked about one line functions in classes that
intentions != results.
After looking at it for longer I think I can make this example a
little more confusing.
```d
int width() => shape.match!(
(Box b) => b.width,
(Circle c) => c.radius * 2
);
```
More information about the Digitalmars-d
mailing list