this post was submitted on 11 Dec 2023
26 points (77.1% liked)

JavaScript

1700 readers
6 users here now

founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 2 points 11 months ago* (last edited 11 months ago)

Yeah, a switch expression is different than a switch statement. I'm not actually sure how many languages actually have them, but in C# its...

var output = input switch
{
    null    => "Null",
    0       => "Zero",
    > 0     => "Positive",
    _       => "Negative"
};