Match Expression vs Switch: Pattern Matching Showdown

PHP 8's match expression vs JavaScript switch. Which language's control flow is more elegant? You won't believe this!

#php #javascript #phpvsjavascript #matchexpression #switchstatement #patternmatching #php8 #programmingcomparison #codecomparison #controlflow #viralcoding

https://www.youtube.com/watch?v=BiiJf3Cpbsk

Match Expression vs Switch: Pattern Matching Showdown #PHP

YouTube

There is a question that I am asking myself today. More like a switch statement, for my programmer friends. I am not looking for advice or opinions, I am just mulling it around in my head.

Should I go to the sugar free bakery today and get some sweet sugar free cookies to have as after dinner snacks this week?

Or, should I bake that sugar free chocolate cake mix that has been in the cupboard for a couple of months now?

Or, should I do neither and just work my way through the pile of sugar free snacks I’ve hoarded over the last month or so?

Now, for the programmers… I asked Google Gemini to write me a switch statement in C that asks those three questions. Here’s what it gave me.

#include <stdio.h>int main() { int choice; printf("Should I go to the sugar-free bakery, or should I bake a sugar-free cake,\nor should I just eat the snacks I've hoarded over the last month?\n"); printf("Enter your choice (1 for bakery, 2 for baking, 3 for snacks): "); scanf("%d", &choice); switch (choice) { case 1: printf("Going to the sugar-free bakery seems like a good option!\n"); break; case 2: printf("Baking a sugar-free cake at home can be a fun and rewarding experience.\n"); break; case 3: printf("Indulging in your hoarded snacks might be tempting, but consider the nutritional value and long-term effects.\n"); break; default: printf("Invalid choice. Please enter 1, 2, or 3.\n"); } return 0;}

https://robertjames1971.blog/2024/10/20/question-for-myself/

#cProgramming #code #diet #nutrition #sugarFree #sugarFreeSnacks #switchStatement #toDoList

Question for Myself

There is a question that I am asking myself today. More like a switch statement, for my programmer friends. I am not looking for advice or opinions, I am just mulling it around in my head. Should I…

Inside the Red Head's Head

Switch Statement in Java 21 – Was lange währt, wird endlich gut! 💻

Das Switch Statement in Java hat mit Version 21 einen grossen Sprung gemacht. 🎉 Mit Pattern Matching, Null-Safety und Unterstützung für Enums und Sealed Classes eröffnet es neue Möglichkeiten. Schluss mit unhandlichen Schreibweisen und unsauberen Workarounds – Java 21 bringt endlich die lang ersehnten Verbesserungen!

https://www.puzzle.ch/blog/2024/09/11/java-switch-statement

#Java21 #SwitchStatement #JavaProgramming

Java: Switch Statement

Das Switch Statement hat in Java schon eine lange Tradition hinter sich. Bisher war die Ausdrucksweise etwas holprig, je nach Compiler und Restriktionen nicht wirklich handlich. Ab Java 12 wurde das Switch Statement schrittweise verbessert, mit Java 21 stehen nun vielseitige Möglichkeiten zur Verfügung, ganz nach dem Motto «Was lange währt, wird endlich gut»

Puzzle ITC