I see in the Rhino source code the following code:
// Summary:
// Or operator for constraints
public static AbstractConstraint operator |(AbstractConstraint c1, AbstractConstraint c2);
But in practice, I can use either | or ||.
Similarly, both & and && work the same way.
Why is this happening?
This is actually a C# issue. You can't overload the conditional logical operators -
&&
and||
directly, in order to overload them the programmer has to overload the&
,|
,true
andfalse
operators, and those operators are used to evaluate an expression containing the&&
and||
operators. More details in this article.Concerning Rhino Mocks, he chose to implement the
true
andfalse
operators in a way that prevents short circuiting and makes the&&
and||
operators equivalent to&
and|
, ILSpy output: