Given that out and ref parameters have slight different connotations would writing code like below be considered a bug (even though it doesn't cause an issue at present), or just a lack of understanding on ref and out parameters?
public void MyMethod()
{
int myInt = 0;
MyMethodWithRef(ref myInt);
}
public void MyMethodWithRef(ref myInt)
{
// not used before being assigned a value. Does an out parameter make more sense then
myInt = 5;
}
I understand that this is the incorrect usage of ref but if you saw that in code constantly or even once would you consider it a bug and hence fix it as well as inform the original coder or just do it as part of general refactoring practices?
refandouthave the same semantics in this case, then it can't be a bug, by definition. It might by stylistically incorrect, though. – Mason Wheeler Jan 25 at 2:54refis that the input value inmyIntis not ignored. – Ross Patterson Jan 25 at 5:22