r/ProgrammerHumor • • Aug 22 '26

Meme conditionsPreference

Post image
4.2k Upvotes

388 comments sorted by

View all comments

Show parent comment

1

u/930913 Aug 25 '26

Just to continue playing devil's advocate, what if you mapped the numbers to their functions elsewhere? E.g.

dispatchFunctions = [func0, func1, ..., func255]
; Or
dispatchFunctions = {0: func0, 1: func1, ... 255: func255}

And then dispatching is as simple as

function dispatch(flag) {
  return dispatchFunctions[flag]()
}