Lua Programming/How to Lua/coercion

In lua, coercion can take place allowing string and numeric values to be converted to the correct format in order to perform calculations:

print ("8" * 4)    -- coercion can take place on numerical strings

Coercion cannot take place on meaningless valuesEdit

print ("h" * 4)    -- coercion cannot take place on non numerical strings

Coercion does not take place for comparative operatorsEdit

print ("9" > 8)    -- coercion does not take place for comparative operators
Last modified on 9 March 2011, at 20:56