Skip to content

Commit a7a2ece

Browse files
authored
Fixed a typo
1 parent f149bb3 commit a7a2ece

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

data/part-6/4-scope-of-variables.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ The basic principle here is that the main function "stores" the data processed b
240240

241241
If the numbers are needed in some function, the variable is passed as an argument, as seen above when the functions `print_result` and `analyze` are called. If the function produces a result that is relevant elsewhere in the program, the function returns this with a `return` statement, as seen with the functions `input_from_user` and `analyse` above.
242242

243-
As always in programming, there are many ways to arrive at the same functionality. It would be possible to use the keyword `global` and have the functions directly access the `inputs` variable defined in the main function. There are good reasons why [this is not a smart move](https://softwareengineering.stackexchange.com/questions/148108/why-is-global-state-so-evil), however. If many different functions can access and potentially change a variable directly, it quickly becomes impossible to reliably track the state of the program, and the program risks becoming unpredictable. This is especially the case as the number of function involved grows large, as it is wont to do in large software projects.
243+
As always in programming, there are many ways to arrive at the same functionality. It would be possible to use the keyword `global` and have the functions directly access the `inputs` variable defined in the main function. There are good reasons why [this is not a smart move](https://softwareengineering.stackexchange.com/questions/148108/why-is-global-state-so-evil), however. When many different functions can access and potentially alter a variable directly, it becomes difficult to reliably track the program's state, which can make the program unpredictable. This is particularly true as the number of functions involved increases, which is common in large software projects.
244244

245245
In conclusion, passing data into and out of functions is best handled by arguments and return values.
246246

0 commit comments

Comments
 (0)