Replies: 1 comment 2 replies
-
You can use sharplab to see what the patterns are currently translated into (https://sharplab.io/#v2:EYLgtghglgdgPgAQEwEYCwAoBBmABM3AYVwG9NcL88EAWXAWQAoBKU8yjhFATkcIBsIAZyFQAZgE9GKbM2YBuCgHoluAPYBXAC4AHbSFwAVNWtwALKAHMz7DhS68Bw0ZMYATTcH4BTAHQA5CH85RVwVdW09LQMAVRgAaxg1AHcYWzsHPkERcSkkXxoQ5VVNXX1cAEEAYyrvHS0IL29MdM4UADZ8FAAGImyXKQ8NJtwwb2ENACdvMZgtVgBeAD5R8aEpme853CFkqC0qmww7SjJjk7sAHlwAWhpfXuXcACJjU34U54AaVouVnoeuCerxM5isZm+vxOQyaASCQJWzziiRSMEh5wulAA+giXtVavVGj50ZiAL7ydKkzCkoA) In this case, if (!(measurement < -4.0))
{
if (!(measurement > 10.0))
{
if (double.IsNaN(measurement))
{
return "Unknown";
}
return "Acceptable";
}
return "Too high";
}
return "Too low"; -- Noting that sharplab only shows the current. What the compiler emits here can change over time or based on changes to the pattern in your own code. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
In this article,
case double.NaN
appears in relational pattern, and logical pattern.But how it is specified?
Because
double == double.NaN
is always false, I think there are some intrinsic support fordouble
(andfloat
), but it is not mentioned in this article.Further more, could we use custom NaN like value in switch?(e.g. quadruple-precision float NaN)
Beta Was this translation helpful? Give feedback.
All reactions