If have the following statement:
return this.revision.HasValue ? this.revision : throw new InvalidOperationException();
I thought it would compile as the throw is breaking the normal flow and it shouldn't be a problem to not return a value but it does not build.
Is there a way to put right this statement or why is this not allowed?
Thanks.
EDIT: this.revision is int? and the method returns int.
EDIT 2: if I have this method
public int Test()
{
throw new Exception();
}
The compiler does not complain about not returning a value, I expected the same thing from an inline if ... at least we know that can be done as it's already done in methods.