Reputation: 379
In the course of working with some as2 code from our dev team, I came across a baffling handful of statements where variables were set to themselves. Is there some reason for such a redundancy that I'm not thinking of?
I'm talking literally like this:
function timeLine(x,w){
x = x;
p = ((x) * 100) / w;
t = v.totalTime;
n = (t * p) / 100;
n = n;
What am I missing? (While we're at it, what's with (x)? I assume it used to be (x + z)...)
Upvotes: 3
Views: 119
Reputation: 179086
Why would a function state
myVariable = myVariable;
?
Because the programmer who wrote it was incompetent. You're not missing anything, whomever wrote that code originally didn't know what they were doing.
If that was AS3 code, it might be possible that they're setting a class variable from the function parameter, but that's best done explicitly using this
to show that the variables are different:
function foo(bar, baz) {
this.bar = bar;
this.baz = baz;
}
Additionally AS3 has accessors and mutators that could cause side-effects. If this was the case, the programmer would not just be incompetent, but dangerous as well.
Upvotes: 4