[Gambas-user] "=" versus "==" in IF statement

T Lee Davidson t.lee.davidson at gmail.com
Thu Apr 2 17:50:20 CEST 2020


On 4/2/20 10:14 AM, Yahoo via User wrote:
> Hello,
> 
> I think only A = 1 is available in Gambas for test
> but assignment using ‘==‘ exist for strings
> 
> Take a look here: http://gambaswiki.org/wiki/lang/stringop
> 
> 
> Olivier

Actually '==' is not an assignment. It is a case-insensitive test:

   Print "Gambas is Great" = "gambas is great" ' Prints False
   Print "Gambas is Great" == "gambas is great" ' Prints True

The '=' operator is used for both assignment and testing depending on the context. This means that you cannot do an assignment 
(even in parentheses) within the conditional part of a test statement such as IF, WHILE, and UNTIL.


-- 
Lee


More information about the User mailing list