T
13

Finally figured out why my functions kept breaking - it was variable scope the whole time

2 comments

Log in to join the discussion

Log In
2 Comments
jamiekim
jamiekim6d ago
Variable scope being the problem actually sounds like an EXCUSE for sloppy coding practices. If you wrote everything in ONE function from the start you never would have had that issue. People overcomplicate things by splitting code into a million tiny pieces then act SURPRISED when variables don't behave. Global scope is perfectly fine for smaller projects and most scripts don't need that level of isolation. You are just making extra work for yourself by trying to be "clean" when the problem was never that deep. Maybe stop overthinking and just write code that works.
2
wilson.jana
Have you actually tried debugging a 500-line function before?
1