Expressions and operators

Just like any programming language, Lua supports basic arithmetic expressions and comparison operators. These are valuable tools in your app-making arsenal and will help you get the most out of Lua. Let's take a look at the expressions and operators that you can use in Lua.

Arithmetic expressions

Lua supports all the basic math functionalities: addition (+), subtraction (-), multiplication (*), and division (/). In addition to these basic functions, you also have the ability to use the modulus (%) and exponents (^) expressions. You can use the modulus expression to retrieve the remainder of a division, and the exponents expression will multiply a number by itself based on the value of the exponent.

Comparison operators

In addition to arithmetic expressions, you also have access to basic comparison operators. The comparison operators are as follows:

  • Equality (==)
  • Inequality (~=)
  • Less than (<)
  • Greater than (>)
  • Less than or equal to (<=)
  • Greater than or equal to (>=)
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.105.105