Setting struct as default parameter of a function using struct literal?

Salih Dincer salihdb at hotmail.com
Mon Sep 11 18:24:01 UTC 2023


On Monday, 11 September 2023 at 17:51:04 UTC, BoQsc wrote:
>
> Here is an example of what I would hope for to work but it 
> surely does not work:

If I were you I would use enum, look at my code:

```d
enum Options
{
   silenceErrors = false
}

void someFunction (Options option = Options.silenceErrors)
{
   writeln(cast(bool)option); // false
}

import std.stdio;
void main()
{
   someFunction();
}
```

SDB at 79



More information about the Digitalmars-d-learn mailing list