Why use the standard declaration when you can use global? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why use the standard declaration when you can use global?

13th Feb 2017, 9:10 AM
Eugenio Santos Jr.
Eugenio Santos Jr. - avatar
2 Answers
0
You may want to use the same variable name in two different classes. Promoting every var to a global not only slows down your code due to overloading, but screws up the OOP coding.
14th Feb 2017, 11:26 AM
Dimitar
Dimitar - avatar
0
Technically, because we aren't using OOP in this example, all the code is in the global scope. That said, it's generally unwise to declare variables global as it makes testing much more complex.
15th Feb 2017, 11:42 PM
Chris Winikka
Chris Winikka - avatar