Default function parameters of other function parameters

Adam D. Ruppe destructionator at gmail.com
Wed Oct 31 01:51:38 UTC 2018


On Tuesday, 30 October 2018 at 21:54:11 UTC, Your name wrote:
> I think it would be nice if default function parameters could 
> be defined as other parameters to the function, like this:

You can't do that, but you can do

this(int initialWidth, int initialHeight) {
   width = initialWidth;
   height = initialHeight;
}
this(int initialWidth) {
   this(initialWidth, initialWidth);
}


and it isn't a huge amount of code to add and forward and quite 
flexible in various options.

> there should really be a way to embed snippets of code 😆!

You just type it up lol we can all read it.


More information about the Digitalmars-d mailing list