--- class A {} class B {} auto alwaysReturnNull() // void*, don't compile { writeln(); return null; } A testA() { return alwaysReturnNull(); } B testB() { return alwaysReturnNull(); } void main() { assert( testA() is null ); assert( testB() is null ); } --- OMG, isn't it nice that this works ?I think that this illustrates an non intuitive behavior of auto return types. One would rather expect auto to work depending on the inner return type.
Unexpectedly nice case of auto return type
Basile B. via Digitalmars-d-learn Mon, 02 Dec 2019 23:16:09 -0800
I wish something like this was possible, until I change the
return type of `alwaysReturnNull` from `void*` to `auto`.
- Unexpectedly nice case of auto retu... Basile B. via Digitalmars-d-learn
- Re: Unexpectedly nice case of ... Basile B. via Digitalmars-d-learn
- Re: Unexpectedly nice case... Andrea Fontana via Digitalmars-d-learn
- Re: Unexpectedly nice ... Basile B. via Digitalmars-d-learn
- Re: Unexpectedly n... Basile B. via Digitalmars-d-learn
- Re: Unexpecte... Andrea Fontana via Digitalmars-d-learn
- Re: Unexp... mipri via Digitalmars-d-learn