0 0
Read Time:36 Second

The relational pattern allows the <, >, <=, and >= operators to appear in patterns:

string GetWeightCategory (decimal bmi) => bmi switch {
 < 18.5m => "underweight",
 < 25m => "normal",
 < 30m => "overweight",
 _ => "obese" };

With pattern combinators, you can combine patterns via three new keywords (and, or, and not):

bool IsVowel (char c) => c is 'a' or 'e' or 'i' or 'o' or 'u';
bool IsLetter (char c) => c is >= 'a' and <= 'z'
 or >= 'A' and <= 'Z';

As with the && and || operators, and has higher precedence than or. You can override this with parentheses.

The not combinator can be used with the type pattern to test whether an object is
(not) a type:

if (obj is not string) ...
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

About Author

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

One thought on “Pattern-matching improvements

  1. For anyone who is interested in the environmental hardships, it could gift all of them are aware that to bring about merely one field hard more than a little flowing shoots reasoning better liters pertaining to oil and gas to bring about. dc free mommy blog giveaways family trip home gardening house power wash baby laundry detergent

  2. I have seen lots of useful items on your site about computers. However, I have got the opinion that notebooks are still more or less not powerful more than enough to be a good selection if you often do projects that require many power, just like video editing and enhancing. But for internet surfing, word processing, and majority of other prevalent computer functions they are all right, provided you may not mind the screen size. Many thanks for sharing your thinking.

  3. I was just seeking this information for a while. After 6 hours of continuous Googleing, finally I got it in your site. I wonder what’s the lack of Google strategy that do not rank this type of informative web sites in top of the list. Generally the top websites are full of garbage.

Leave a Reply

Your email address will not be published. Required fields are marked *