Reader small image

You're reading from  Corona SDK Mobile Game Development: Beginner's Guide

Product typeBook
Published inMar 2015
Publisher
ISBN-139781783559343
Edition1st Edition
Tools
Right arrow
Author (1)
Michelle M Fernandez
Michelle M Fernandez
Right arrow

Expressions


An expression is something that represents a value. It can include numeric constants, quoted strings, variable names, unary and binary operations, and function calls.

Arithmetic operators

+, -, *, /, %, and ^ are called arithmetic operators.

Here is an example of binary arithmetic operators:

t = 2*(2-5.5)/13+26
print(t)  -- 25.461538461538

An example of the modulo (division remainder) operator is as follows:

m = 18%4
print(m)  -- 2

An example of the power of operator is as follows:

n = 7^2
print(n)  -- 49

Relational operators

Relational operators always result in false or true and ask yes or no questions. The relational operators are <, >, <=, >=, ==, ~=.

The == operator tests for equality, and the ~= operator tests for inequality. If the value types are different, then the result is false. Otherwise, Lua compares the values to their types. Numbers and strings are compared in the usual way. Tables and functions are compared by reference as long as two such values are considered...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Corona SDK Mobile Game Development: Beginner's Guide
Published in: Mar 2015Publisher: ISBN-13: 9781783559343

Author (1)