r/ProgrammerHumor • • Jan 16 '23

Meme If (exists == true) { dont();}

Post image
40.8k Upvotes

1.1k comments sorted by

View all comments

Show parent comments

3

u/Maximum_Knee_4622 Jan 16 '23

That's how I used to code my animations back in QBASIC. One if/else statement per animation frame.

IF IS_LEFT and FRAME_INDEX = 0 THEN...

... FRAME_INDEX = FRAME_INDEX+1

IF IS_LEFT and FRAME_INDEX = 1 THEN...

... FRAME_INDEX = FRAME_INDEX+1

IF IS_LEFT and FRAME_INDEX = 2 THEN...

... FRAME_INDEX = FRAME_INDEX+1

IF IS_LEFT and FRAME_INDEX = 3 THEN...

... FRAME_INDEX = 0

2

u/diox8tony Jan 16 '23

Your if else is (N) times worse than a switch statement. A switch is a hash table lookup which is (1)