C
Caddzooks
Hi
public class Class1
{
public void test()
{
bool result = true;
result |= foo(); // foo() always called.
result = result || foo(); // foo() not called
}
public bool foo()
{
return false;
}
}
The question is quite simply, if I can use 'var |= arg' to do the functional equivalent of 'var = var || arg', why does |= evaluate the right side when the result is already known (e.g, the value being assigning is true) ?
I undertstand why this happens in C++, but in C#, the |= operator is operating on bool operands.
--
caddzooks
public class Class1
{
public void test()
{
bool result = true;
result |= foo(); // foo() always called.
result = result || foo(); // foo() not called
}
public bool foo()
{
return false;
}
}
The question is quite simply, if I can use 'var |= arg' to do the functional equivalent of 'var = var || arg', why does |= evaluate the right side when the result is already known (e.g, the value being assigning is true) ?
I undertstand why this happens in C++, but in C#, the |= operator is operating on bool operands.
--
caddzooks