this post was submitted on 11 Dec 2023
32 points (79.6% liked)

JavaScript

1982 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 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"
};