On Thursday, 5 January 2023 at 23:31:36 UTC, Vladimir Marchevsky wrote:
On Thursday, 5 January 2023 at 21:48:40 UTC, Vijay Nayar wrote:

2. Using a constructor with many arguments.
```
A a = new A("Bob", 20, false, true);
```

This approach can construct arguments inline, such as during a function call, however, the arguments are not labeled, making it easy to get the order wrong or for the meaning to be unclear.

Hopefully we'll finally have named arguments. Considering they were accepted to language more than two years ago - maybe in the next century...

Named arguments would definitely obviate this tool, but in the meanwhile, this tool basically lets you achieve the same objectives in terms of single-expression construction and clearly labeled arguments. I guess one extra advantage of the `builder` library is that you also don't have to bother writing a constructor at all and can just use the default one.

Reply via email to