[Gambas-user] stupid question about INC and boolean
Stephen Bungay
sbungay at ...981...
Sun Apr 13 02:58:44 CEST 2008
Simply "NOT'ing the boolean accomplishes the same thing...
Dim X as Integer
Dim B as Boolean
For X = 0 to 10
B = Not B
Next
INC or DEC are not logical operators. Just because they can be used
on boolean values the question is should they be used, does it make for
better code clarity?
Stefano Palmeri wrote:
> Alle 19:05, sabato 12 aprile 2008, Benoit Minisini ha scritto:
>> On samedi 12 avril 2008, Stefano Palmeri wrote:
>>> PUBLIC SUB Main()
>>>
>>> DIM iCount AS Integer
>>>
>>> FOR iCount = 0 TO 10
>>>
>>> INC $bBoolValue
>>>
>>> NEXT
>>>
>>> PRINT $bBoolValue
>>>
>>> END
>> Actually I wanted that INC and DEC work on boolean values like toggles.
>>
>> I mean:
>>
>> INC $bBoolValue <=> $bBoolValue = NOT $bBoolValue
>>
>> Same thing for DEC $bBoolValue.
>>
>> Alas there is a bug in Gambas that prevents it from working correctly. I
>> will fix it for the 2.6 version.
>>
>> Regards,
>
> Ok. Anyway in the example TRUE is correct.
> So it works good?
>
> 0 True
> 1 False
> 2 True
> 3 False
> 4 True
> 5 False
> 6 True
> 7 False
> 8 True
> 9 False
> 10 True
>
> I don't want you to fix something that is working good :-)
>
> I just was surprised not getting error while increasing
> a boolean value. Now I know the magic behind and all
> is clear.
>
> Stefano
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> Don't miss this year's exciting event. There's still time to save $100.
> Use priority code J8TL2D2.
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
More information about the User
mailing list