if(bool = x) does not give a boolean result
Steven Schveighoffer
schveiguy at yahoo.com
Fri May 7 04:56:23 PDT 2010
I have code like this in dcollections:
/**
* Removes the element that has the given key. Sets wasRemoved to
true if the
* element was present and was removed.
*
* Runs on average in O(1) time.
*/
HashMap remove(K key, out bool wasRemoved)
{
cursor it = elemAt(key);
if(wasRemoved = !it.empty)
{
remove(it);
}
return this;
}
However, this does not compile with the following message:
dcollections/HashMap.d(561): Error: '=' does not give a boolean result
line 561 is the if statement.
Since when did bool = bool not give a bool result?
Do I have to write it out like this:
if((wasRemoved = !it.empty) == true)
I can understand for ints and strings and whatnot, but for booleans?
-Steve
More information about the Digitalmars-d-learn
mailing list