122

A wife tells her programmer husband: β€œGo to the store and buy a gallon of milk. If they have eggs, get six.”

He comes back with six gallons of milk. When she asks why, he replies: β€œThey had eggs".

you are viewing a single comment's thread
view the rest of the comments
[-] ignirtoq@feddit.online 7 points 3 months ago

Python, though the logic would be backwards:

milk_gallons = 6 if eggs > 0 else 1
[-] dnick@sh.itjust.works 0 points 3 months ago

Right, it would be started basically exactly the opposite. Certainly not a statement followed by an if block.

[-] ignirtoq@feddit.online 1 points 3 months ago

The code block I wrote is a statement followed by an if. What I meant be "backwards" was the order of conditions, not that the statement came after the if. It's exactly what you asked for.

this post was submitted on 13 Jan 2026
122 points (89.6% liked)

Programmer Humor

31092 readers
9 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS