On Sunday, 29 October 2017 at 17:19:44 UTC, Jonathan M Davis
wrote:
On Sunday, October 29, 2017 16:44:39 Ola Fosheim Grøstad via
Digitalmars-d wrote:
On Sunday, 29 October 2017 at 16:29:57 UTC, Jonathan M Davis
wrote:
> valid using ?:, I would think that you'd want to be doing
> the same check with stuff like if statements anyway. So, it
> sounds to me like overloading opCast!bool would work just
> fine.
If you try to do:
some_float ?: 0.0
then it will do nothing as cast(bool)std.math.NaN(0) => true
NaN is supposed to always be false.
OT, but I had to :-)
```
void main()
{
import std.stdio;
float x;
x? writeln("Oh no, a NaN!") : writeln("All good.");
}
```
Same happens for assert(float.nan) - it doesn't fail.