1 matches bool, 2 matches long

Mike James foo at bar.com
Mon Apr 29 07:08:17 PDT 2013


> gdc:
>
> bool x = false;
> x++;
>
> main.d:50: Error: operation not allowed on bool 'x'
>
> why not? is just an integer after all. another special case?

If you are going to create a boolean then use it as a boolean - it's not an 
integer any more. Don't mix and match - there's nothing worse than trying to 
follow some code that uses a variable in one way then, out of lazyness, uses 
it in a different way.

>
> this works:
>
> int x = false;
> x++; 



More information about the Digitalmars-d mailing list