error in return statement
downs
default_357-line at yahoo.de
Fri Feb 13 16:03:27 PST 2009
zorran wrote:
> possibly error in return statement:
> ====
> bool fn1(Object o1, Object o2 ) {
> return o1.opEquals(o2); // opEquals return int
> }
> ====
>
> compiler writes:
> "Error: cannot implicitly convert expression (o1.opEquals(o2)) of type int to bool"
>
> But:
> ====
> bool fn2() {
> return 1;
> }
> ====
> compile ok!
>
> DMD 1.039
A quick way around this is the !! "operator", i.e. double negotiation. "return !!o1.opEquals(o2); "
It should be clear how this works. If not, try to think of !!a as !(!(a)).
More information about the Digitalmars-d-bugs
mailing list