
If a is true, returns A, otherwise returns b. If a is false, return a, otherwise return b. We can understand the application of relational operator better through the following examples:ī = 10 if ( a = b ) then print ( "Line 1 - a equals to b" ) else print ( "Line 1 - a not equal to b" ) end if ( a ~= b ) then print ( "Line 2 - a not equal to b" ) else print ( "Line 2 - a equals to b" ) end if ( a b ) then print ( "Line 4 - a is greater than b" ) else print ( "Line 5 - a is less than or equal to b" ) end - Modify the values of a and bī = 20 if ( a = a ) then print ( "Line 6 - b is greater than or equal to a" ) end -Execution Result: -Line 1 - a not equal to b -Line 2 - a not equal to b -Line 3 - a is greater than or equal to b -Line 4 - a is greater than b -Line 5 - a is less than or equal to b -Line 6 - b is greater than or equal to a logical operator OperatorĪND operator. check if the value on the left is equal or less than the value on the right. If yes return true, if not return falseĮqual or less than. check if the value on the left is equal or greater than the value on the right. If yes return true, if not return falseĮqual or great than. check if the value on the left is greater than the value on the right. checks whether the two values are equal,if equal returns false, if not return true checks whether the two values are equal, if equal returns true, if not return false The following table lists the commonly used relational operators in Lua language, setting the value of a to 10 and the value of b to 20: OperatorĮqual to.

Print ( "value of Line 7 - c is ", c ) -Print result: -value of Line 1 - c is 31 -value of Line 2 - c is 11 -value of Line 3 - c is 210 -value of Line 4 - c is 2.1 -value of Line 5 - c is 1 -value of Line 6 - c is 441 -value of Line 7 - c is -21 relational operator Represents a separate line of execution used to execute a coroutineĬ = a ^ 2 print ( "value of Line 6 - c is ", c ) Represents any C data structure stored in a variable # Lua Data Type Data NameĪn invalid value(The equivalent of false in a conditional expression)īoolean value containing two values: false and trueĪ real number, representing a real floating point number of type double, or an integerĪ string, represented by a pair of single or double quotesĪ data structure of Lua, used to create different data types, such as arrays, dictionaries, and etc In other words, a variable only exists when it is not equal to nil. Closures and tables make it easy to support some of the key mechanisms required for object-oriented programming, such as data abstraction, virtual functions, inheritance, and overloading.Ĭhat : sendSystemMsg (b, 0 ) -undeclared variable b, no error, but the printed result is nil -Ĭhat : sendSystemMsg (b, 0 ) -declared variable b, the printed result of b is 10 -If you want to delete a global variable, just assign nil as valueĬhat : sendSystemMsg (b, 0 ) -So it's like the variable b has never been used.Language built-in pattern matching Closure The function can also be viewed as a value Support for multi-threading (collaborative processes, not threads supported by the operating system).Automatic memory management Only one generic type of table is provided, which can implement arrays, hash tables, collections and objects.


Support procedure-oriented and functional programming).

Flexible extension: Lua provides easy to use extension interfaces and mechanisms: these functions are provided by the host language (usually C or C++), and Lua can use them as if they were already built in.File size around 100 kilobytes after compiled, which can be easily embedded in other programs.
#Lua model kits cavorite sphere code
