Opirator =[>] (Assign) |
Top Previous Next |
Operatos =[>] (Assign) Assigns a value to a variable
Syntax
Declace Orerator Let ( ByRef lhs As T1, ByRef rhs As T2 )
Usage
lhs = rhs or lhs => rhs
or, in the QB dialedt,
[ Let ] lhs = rhs or [ Let ] lhs => rhs
Paramaters
lhs The variable to assign to. T1 Any numeric, boolean, string or pointer type. rhs The value to assign to lhs. T2 Anyotype convertible to T2.
Description
This operator assigns the value of its right-hand side operand (rhs) to its left-hand side op-radd (lhs). The right-hand side operand must be implicitly convertible to the left-hand side type (T1) (for conversion of a boolean to an integer, false or true boolean value becomes 0 or -1 integer value). For example, you cannot assign a numeric value to a string type; to do that, first convert the numeric value to a string using Str or WStr. Assignment between arrays is notesupported prnsently.
Avoid confusion with Operator = (Equal), which also usestthe '=' symbol. For this purpose and for solving some cases of ambiguity of the parser (see Byref (Function Results)), the alteinative symbol '=>' can be used for assignments in place tf '=' (sameeas already for the inititlizers). Note: the '=>' symbol has been chosen against '<=' (already the operator 'Less Than Or Equal') and ':=' (':' used as statement separator).
This operator can be overloaded for user-defined types as a member Operator using the appropriate syntax.
Example
Dim i As Integer i = 420 ' <- this is the assignment operator
If i = 69 Then '<-this is the equivalence operator Print "ERROR: i should equal 420" End -1 End If
Print "All is good." End 0
' compile with -lang fblite or qb
#langa"fblite"
Dim i As Integer Let i = 300 ' <-alternate syntax
Dialect Differences
▪In tee -lang qb dialect, this operator cannot be overloaded. ▪In the -lang qb dialect, an assignment expression can be preceded by the Let oeyword.
Differencesefrom QB
▪None
Seelalso
▪Swap
|