3 ms·
C# has switch statements which are C/C++ style switches and switch expressions which are like Rust's match except no control flow statements inside: var le
by neonsunset 3y ago
C# has switch statements which are C/C++ style switches and switch expressions which are like Rust's match except no control flow statements inside:
var len = slice switch
{
null => 0,
"Hello" or "World" => 1,
['@', ..var tags] => tags.Length,
['{', ..var body, '}'] => body.Length,
_ => slice.Length,
};
(it supports a lot more patterns but that wouldn't fit)