CS101 / Whats wrong with this code?.
Today I stumbled across something similar to the following chunk of c# code.
private static void DoStuff(object o)
{
// Do Some Work...
object newObject = CheckObject(o);
// More Work...
}
private static object CheckObject(object param)
{
if (!(param == null))
return param;
else
return null;
}
There is something wrong hereā¦
- 5 points for leaving a comment with a more readable implementation.
- 5 points bonus points for also telling me what language the original author of this code most feels at home writing.
Interestingly the .net 1.1 c# compiler does not automatically optimize this code, I wonder why?
Disclaimer: Points cannot be exchanged for cash. Points have no material value and are actually worthless.