this post was submitted on 11 Dec 2023
29 points (78.4% liked)

JavaScript

1961 readers
1 users here now

founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] JakenVeina@lemm.ee 2 points 10 months ago* (last edited 10 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"
};