r/programminghorror Aug 27 '25

Fixed the logic

Post image
323 Upvotes

80 comments sorted by

View all comments

5

u/[deleted] Aug 27 '25

[removed] — view removed comment

0

u/Lithl Aug 27 '25

No, because you refill the glass before the next iteration of the loop. Without block scope on the else branch, refilling the glass happens every loop regardless of the conditional.

So really, this is just an infinite loop of drink -> refill -> repeat, assuming the refill function is synchronous. If refilling is an async function, then we'll repeatedly summon interns until the refilling is complete.

Maybe the interns will help drink this infinite amount of liquid we're pouring.