1 Resposta
+ 1
Pure:
a = 20
def f9(x):
return x*2
a = f(4)
Impure:
a = 20
def f9(x):
a = x * 2
f9(4)
In both variable a value was changed from 20 to 8
Now look about the Impure version. Think about if the f9 definition of impure function was moved to the Moon. How would you then know while reading the code that a's value is changed when f9 is called? That's one example, where using impure function reduces the readability.