Integer precision of function return types
thinkunix
thinkunix at zoho.com
Fri Sep 27 04:23:32 UTC 2024
Per Nordlöw via Digitalmars-d-learn wrote:
> Should a function like
>
> ```d
> uint parseHex(in char ch) pure nothrow @safe @nogc {
> switch (ch) {
> case '0': .. case '9':
> return ch - '0';
> case 'a': .. case 'f':
> return 10 + ch - 'a';
> case 'A': .. case 'F':
> return 10 + ch - 'A';
> default:
> assert(0, "Non-hexadecimal character");
> }
> }
> ```
>
> instead return an ubyte?
What about using 'auto' as the return type?
I tried it and it seemed to work OK.
Wondering if there are any good reasons to use auto,
or bad reasons why not to use auto here?
More information about the Digitalmars-d-learn
mailing list