if(bool = x) does not give a boolean result

Graham Fawcett fawcett at uwindsor.ca
Fri May 7 05:02:00 PDT 2010


On Fri, 07 May 2010 07:56:23 -0400, Steven Schveighoffer wrote:

> 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?

Don't you mean bool == bool, not bool = bool?

Graham


More information about the Digitalmars-d-learn mailing list