C
cody
What if i want to validate the return value of a method but this method has
serveral points where a return statement is.
I know in MSIL there is only one RET opcode in each method and this means
that the method always knows its return value at this point.
int GetValue()
{
try
{
// calculate value, severals return's here
if (a<b)return b;
else if (a==1) return b+1;
else if (b==1) rerturn a-1;
else return 2;
}
finally
{
System.Diagnostics.Debug.Assert(retval!=0); // new keyword retval
}
}
I know I also could use a variable where I store the return value but that
would mean to introduce a new variable.
In Pascal you could access the return value using the function's name.
What do you think?
serveral points where a return statement is.
I know in MSIL there is only one RET opcode in each method and this means
that the method always knows its return value at this point.
int GetValue()
{
try
{
// calculate value, severals return's here
if (a<b)return b;
else if (a==1) return b+1;
else if (b==1) rerturn a-1;
else return 2;
}
finally
{
System.Diagnostics.Debug.Assert(retval!=0); // new keyword retval
}
}
I know I also could use a variable where I store the return value but that
would mean to introduce a new variable.
In Pascal you could access the return value using the function's name.
What do you think?