merari42@lemmy.world to Programmer Humor@programming.dev · 3 days agoWishUnderflowlemmy.worldimagemessage-square39fedilinkarrow-up1469arrow-down112
arrow-up1457arrow-down1imageWishUnderflowlemmy.worldmerari42@lemmy.world to Programmer Humor@programming.dev · 3 days agomessage-square39fedilink
minus-squarebalsoft@lemmy.mllinkfedilinkarrow-up4·3 days agoYou decrement the wish counter first, execute the action (which includes waiting those 5 days), and if it fails you increment the counter back. Something like this: wishes = wishes - 1; executeWish(wish).unwrap_or_else(|_| { wishes = wishes + 1; })? This way if the action fails in the future, you get a wish back and can ask something else.
You decrement the wish counter first, execute the action (which includes waiting those 5 days), and if it fails you increment the counter back. Something like this:
wishes = wishes - 1; executeWish(wish).unwrap_or_else(|_| { wishes = wishes + 1; })?
This way if the action fails in the future, you get a wish back and can ask something else.