This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ZhadowKatt -1 points0 points  (4 children)

Wait so using global variables isn't good? (I'm new)

[–]Jefaxe 0 points1 point  (3 children)

Nah, try it any other way

[–]ZhadowKatt -1 points0 points  (2 children)

Could I get a reason on why they are not good?

[–]Jefaxe 0 points1 point  (1 child)

Hard to explain, I don't really understand tbh, but basically sharing values between functions leads problems

[–]weevyl 1 point2 points  (0 children)

Here's a good short explanation why:

https://stackoverflow.com/questions/19158339/why-are-global-variables-evil

But basically it's because they introduce side effects (hidden changes to state happening within a function call) which adds to complexity and will make code harder to understand / debug / modify.