Floating point types default to NaN?

Dukc ajieskola at gmail.com
Mon Nov 27 16:04:14 UTC 2017


On Saturday, 25 November 2017 at 09:39:15 UTC, Dave Jones wrote:
> I mean at the end of the day, that would turn a run time error 
> into a compile time error which is a good thing isnt it?

Debatable in this case. Consider:

string servicePhoneNumber;

final switch (car.manufacturer) //an enumerated value.
{   case CarMaker.Audi:
         servicePhoneNumber = staff["Dorff Hans"].phone;
         //...
     break;
     case CarMaker.Skoda:
         servicePhoneNumber = staff["Telegin Svetlana"].phone;
         //...
     break;
     //more cases ...
}

Here it is arguably unnecessary typing if you had to manually set 
servicePhoneNumber to "" or something at start. And in case of 
structs it tends to be a verbose thing to manually set one to 
it's init value.


More information about the Digitalmars-d-learn mailing list