A couple of extensions to `with` that would be worthwhile
Paul Backus
snarwin at gmail.com
Thu Oct 14 13:46:52 UTC 2021
On Thursday, 14 October 2021 at 08:44:27 UTC, Antonio wrote:
> - I usually take the functional way:
>
> ```d
> (string xpath){
> ...
> }( expandPath(name) );
> ```
>
> And UFCS doesn't help to "beutify" the code. This doesn't work
> (And, in my opinion, should):
>
> ```d
> expandPath(name).(auto xpath){
> ...
> };
> ```
> This neither
>
> ```d
> expandPath(name).((auto xpath){
> ...
> })();
> ```
>
> May be "with" could be an alternative
I sometimes use [`std.functional.pipe`][1] for this:
```d
expandPath(name).pipe!((auto xpath) {
/* ... */
});
```
[1]: https://phobos.dpldocs.info/std.functional.pipe.html
More information about the Digitalmars-d
mailing list