interface inference
Dom DiSc
dominikus at scherkl.de
Tue Nov 28 14:10:30 UTC 2023
On Tuesday, 28 November 2023 at 11:01:14 UTC, Antonio wrote:
> ```d
> I aOrB(bool check){
> if(check)
> return new A();
> else
> return new B();
> }
> ```
>
> **Is it the expected behaviour for ternary conditional?**
Here the compiler knows what type to return (from the function
signature).
But the ternary operator doesn't know this, so its arguments need
to be of the same type (or implicitly convert to a common type).
More information about the Digitalmars-d-learn
mailing list