❔ When setting up menus would you guys say the "If" method or Switch is more suitable?

Which would be the best option?
13 Replies
LPeter1997
LPeter19972y ago
As in... choosing between selection options with an if vs a switch statement? Who cares. For a few options, use if, switch, ... doesn't matter. For many options, you'd likely want to use a switch, just because it's a tiny bit more concise and usually explains intent of mutually exclusive selections better
ero
ero2y ago
spectre.console ¯\_(ツ)_/¯
sunny innit
sunny innitOP2y ago
Thanks for the replies friendos. 🙂 im doing a questionnaire and its been messing me up with these kinds of silly questions
LPeter1997
LPeter19972y ago
If you're using an IDE, you don't even need to worry about these
LPeter1997
LPeter19972y ago
LPeter1997
LPeter19972y ago
Many of these conversions have been automated for you
sunny innit
sunny innitOP2y ago
oooooh thanks 😮 okay so this might be hard to explain butttttttttttttt
sunny innit
sunny innitOP2y ago
sunny innit
sunny innitOP2y ago
this is a diagram of a program that's purpose is; Start Write Logs - choose a menu - quit program write a new statement in log - Search for statements within log read title - read search read text - save input or if the search exists within log - if true - write and present result if false go back to menu Question is, what kind of loop is best suited for this purpose?
ero
ero2y ago
while (true) always
sunny innit
sunny innitOP2y ago
Thanks a ton 😄 and for the patience
Pobiega
Pobiega2y ago
I'd not implement this as a single menu, but rather a main menu that triggers another method that contains sub-menus as needed
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server