I am attempting to use short circuiting between two function calls. Take for example this code:
private void BubbleDown(Graph.Vertex item)
{
BubbleDownLeft(item) || BubbleDownRight(item);
}
Where BubbleDownLeft
and BubbleDownRight
both return a bool. This throws the following error:
Error CS0201 - Only assignment, call, increment, decrement, and new object expressions can be used as a statement
I know I can easily rewrite the function to use an if statement (but that's not as pretty) or even just assign it to a value I don't use:
private void BubbleDown(Graph.Vertex item)
{
bool ignoreMe = BubbleDownLeft(item) || BubbleDownRight(item);
}
So why is my first coding example an error rather than valid or perhaps just a warning?