if Condition expression can't have function?

Matthias Walter via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 25 00:29:51 PDT 2014


On 04/25/2014 09:14 AM, FrankLike via Digitalmars-d wrote:
> Hi,everyone,
> Here has a error after run: " main.exe 11 " or " main.exe 10 ":
> template find(T)
> {
>     size_t find(T[] Array,T Element)
>     {

find returns a size_t being a nonnegativ number.

>     return -1;

But here it returns -1.

In your main code you check find() >= 0, so maybe the compiler
simplifies it in some situations because a size_t value is always >= 0.

Matthias


More information about the Digitalmars-d mailing list