Can a pure function modify a global variable?

  • Yes
  • No
  • It depends
  • Only if it's a constant variable
No, a pure function should not modify global variables or any external state. It should only depend on its input parameters to produce the output and should not have side effects. Modifying global variables violates the principles of pure functions.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *