Click here to Skip to main content
15,349,128 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: When did syntax become so fussy? Pin
Steve Naidamast11-Jun-21 6:18
professionalSteve Naidamast11-Jun-21 6:18 
GeneralRe: When did syntax become so fussy? Pin
raddevus9-Jun-21 10:34
mvaraddevus9-Jun-21 10:34 
GeneralRe: When did syntax become so fussy? Pin
Mircea Neacsu9-Jun-21 10:48
mvaMircea Neacsu9-Jun-21 10:48 
GeneralRe: When did syntax become so fussy? Pin
jathalls11-Jun-21 2:01
Memberjathalls11-Jun-21 2:01 
GeneralRe: When did syntax become so fussy? Pin
raddevus11-Jun-21 9:53
mvaraddevus11-Jun-21 9:53 
GeneralRe: When did syntax become so fussy? Pin
James Lonero12-Jun-21 17:44
MemberJames Lonero12-Jun-21 17:44 
GeneralRe: When did syntax become so fussy? Pin
jathalls12-Jun-21 22:28
Memberjathalls12-Jun-21 22:28 
GeneralRe: When did syntax become so fussy? Pin
Jon McKee9-Jun-21 11:06
professionalJon McKee9-Jun-21 11:06 
Maybe I'm the odd one out but I don't see the issue. It's an expression syntax instead of a statement syntax. Not to mention this syntax forces an expression as the body of a case section so if your intent is to return something then that is enforced, whereas the statement syntax doesn't care. I feel like it's the same difference and motivations between the ternary operator ?: and if-else. Expression vs statement. Something simple that yields a value vs something possibly complex that may or may not.

Also you save space. 6 lines vs 15 lines Poke tongue | ;-P
C#
string x = "test";

int y = x switch {
    "test" => 0,
    "test1" => 1,
    "test2" => 2,
    _ => 3
};

int z = -1;
switch (x) {
    case "test":
        z = 0;
        break;
    case "test1":
        z = 1;
        break;
    case "test2":
        z = 2;
        break;
    default:
        z = 3;
        break;
};

GeneralRe: When did syntax become so fussy? Pin
Wizard of Sleeves10-Jun-21 20:29
MemberWizard of Sleeves10-Jun-21 20:29 
GeneralRe: When did syntax become so fussy? Pin
Jon McKee10-Jun-21 23:33
professionalJon McKee10-Jun-21 23:33 
GeneralRe: When did syntax become so fussy? Pin
Wizard of Sleeves11-Jun-21 1:45
MemberWizard of Sleeves11-Jun-21 1:45 
GeneralRe: When did syntax become so fussy? Pin
Cp-Coder9-Jun-21 12:29
MemberCp-Coder9-Jun-21 12:29 
GeneralRe: When did syntax become so fussy? Pin
Nelek9-Jun-21 19:52
protectorNelek9-Jun-21 19:52 
GeneralRe: When did syntax become so fussy? Pin
Mike Hankey9-Jun-21 13:05
professionalMike Hankey9-Jun-21 13:05 
GeneralRe: When did syntax become so fussy? Pin
James Lonero12-Jun-21 17:46
MemberJames Lonero12-Jun-21 17:46 
GeneralRe: When did syntax become so fussy? Pin
PIEBALDconsult9-Jun-21 14:05
professionalPIEBALDconsult9-Jun-21 14:05 
JokeRe: When did syntax become so fussy? Pin
enhzflep9-Jun-21 23:47
Memberenhzflep9-Jun-21 23:47 
GeneralRe: When did syntax become so fussy? Pin
Maximilien10-Jun-21 2:53
MemberMaximilien10-Jun-21 2:53 
GeneralRe: When did syntax become so fussy? Pin
Marc Clifton10-Jun-21 3:47
mvaMarc Clifton10-Jun-21 3:47 
GeneralRe: When did syntax become so fussy? Pin
obermd10-Jun-21 4:53
Memberobermd10-Jun-21 4:53 
GeneralRe: When did syntax become so fussy? Pin
Gerry Schmitz10-Jun-21 5:26
mveGerry Schmitz10-Jun-21 5:26 
GeneralRe: When did syntax become so fussy? Pin
Gary R. Wheeler10-Jun-21 9:28
MemberGary R. Wheeler10-Jun-21 9:28 
GeneralRe: When did syntax become so fussy? Pin
Jon McKee10-Jun-21 23:54
professionalJon McKee10-Jun-21 23:54 
GeneralRe: When did syntax become so fussy? Pin
Gary Wheeler11-Jun-21 3:55
MemberGary Wheeler11-Jun-21 3:55 
GeneralRe: When did syntax become so fussy? Pin
pmauriks10-Jun-21 19:56
Memberpmauriks10-Jun-21 19:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Straw Poll

What language are you using for AI development or learning?
Whether you're at work or home, hard core coding or just trying to figure out this AI thing, which languages have you used in your adventures?
  Results   80 votes