# IF Statement

An if statement executes a block of code if a specified condition is true.

a = math.random()
b = math.random()
if a < b then
print("Variable a (" .. a ..") is smaller than variable b (" .. b .. ").")
print( a == b ) -- prints false
print( a ~= b ) -- prints true
elseif a > b then
print("Variable a (" .. a ..") is larger than variable b (" .. b .. ").")
else
print("Variable a is equal to variable b.")
end
Note: This example uses another useful Lua module, math, to generate a random number for two variables.