🎙️
7

I was stuck on a loop for two days until I tried rubber duck debugging

I had this function that was supposed to add up a list of numbers, but it kept returning zero. I checked my math, I rewrote the loop three times, nothing worked. Finally, I explained the code line by line to my coffee mug, pretending it was a person. Halfway through saying 'and then it resets the total variable inside the loop,' I realized my mistake. Has anyone else had a simple trick like that actually fix a stubborn bug?
3 comments

Log in to join the discussion

Log In
3 Comments
carr.elliot
Oh, the classic "explaining it to an inanimate object" trick. I love that halfway through telling your mug about the resetting variable, your own brain finally heard how stupid it sounded. My version is pacing around the room complaining out loud to my dog.
8
stella_lane
God, I once explained a bug to my toaster and felt true shame.
5
cameronjenkins
cameronjenkins20d agoMost Upvoted
My cat gets my best debugging rants, but @carr.elliot's dog probably gives better feedback.
6