Is there a nice syntax to achieve optional named parameters?
John Burton
john.burton at jbmail.com
Thu Jan 17 10:29:13 UTC 2019
On Wednesday, 16 January 2019 at 14:59:01 UTC, Kagamin wrote:> On
Tuesday, 15 January 2019 at 11:14:54 UTC, John Burton wrote:
>> auto window = Window(title = "My Window", width = 1000,
>> fullscreen = true);
>
> In this particular case I would make the constructor take 3
> parameters - title, width and height. Full screen is a rare
> functionality and shouldn't clutter the constructor, can it be
> set after the window is created?
Well window was just an example really, my real use case is a
similar
object that needs a lot of configuration where mostly the default
works
but you might want to override, and the config is needed to
create the
object in the first place.
For this example you are right though, and it may be that I'm
overthinking
the whole thing.
More information about the Digitalmars-d-learn
mailing list