Getopt default int init and zero

Jon Degenhardt via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat May 20 09:35:23 PDT 2017


On Friday, 19 May 2017 at 12:09:38 UTC, Suliman wrote:
> I would like to check if user specified `0` as getopt 
> parameter. But the problem that `int`'s are default in `0`. So 
> if user did not specified nothing `int x` will be zero, and all 
> other code will work as if it's zero.

One way to do this is the use a callback function or delegate. 
Have the callback set both the main variable and a boolean 
tracking whether the option was entered.

--Jon


More information about the Digitalmars-d-learn mailing list