I'm having a mental block, can someone remind me what the correct term for returning early from a function is, i.e.
private MyOb开发者_StackOverflow中文版ject DoSomeStuff(string myValue)
{
//What is this called?!?!?
if(myValue == string.Empty)
return null;
MyObject obj = new MyObject();
obj.Value = myValue;
return obj;
}
I believe it's called a guard clause.
I would potentially call this an Interrupt. Or, simply, and Early Return. Break might work, too.
I would call it a "precondition test".
精彩评论