Sometimes when you write code you can go completely round in a circle. As your project & codebase develops, you will perform a process called Refactoring - this is the art of improving and generalising existing code to make it more usable for your new needs.
When you start refactoring, you may have a grand idea in your head of what you can do to improve the code. Along the way though, you may hit a road block causing you to write something a little bit hacky & inelegant to complete the refactor. Your gut will twinge, but you will ignore it and say "everything is nice now".
Like a loose thread on a jumper, you will (very quickly) pull on the one in-elegancy and shortly after, everything will turn ugly. What you have now is worse than what you began with, so you cut your losses and go back to the drawing board. But the time is not wasted! Any failed attempt pushes the limits of what you know to be possible - when you think again of how to refactor you will remember your previous attempt and avoid that route.
Fail as many times as you like; you only need to succeed once