I’m not sure if this is a bug or intended by design but i was hoping someone here would have more of an idea as to why it happens.
Consider this code
var someMetric = GetMetric(); // returns 3000
var someNullableMetric = GetNullableMetric(); // returns null
// Doesn't work
var total = someMetric + someNullableMetric; // why does this return null and not throw an error?
var Total = someMetric + someNullableMetric ?? 0; // why is '+' done prior to '??'
// Works
var Total = someMetric + (someNullableMetric ?? 0); // this understandably works
Just looking for an explanation as this functionality was totally unexpected, null coalescing operator doesnt fall into BODMAS so i would have assumed it would have been executed first(although last kind makes more sense now im typing it out)? or an exception would have been thrown for trying to add null to a value.