#SwitchStatement

2024-10-20

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

2024-09-12

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!

puzzle.ch/blog/2024/09/11/java

#Java21 #SwitchStatement #JavaProgramming

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst