I know that pure functions shouldn't mutate state that's not passed in as a parameter but I don't know if the this
keyword is an exception to that rule. Here is a simple example of what I'm thinking:
class Car {
color: string = 'red';
make: string = 'Dodge';
constructor() {}
changeMake(newMake: string): string {
this.color = 'blue'; // <-- Is this impure?
return newMake;
}
}
Is this impure? Why, or why not?