Article
home/blog/Loading

All about functions in LUA

Functions are the core of any good program or script. Functions in LUA are in the following format

Basic function

function name()
 -- some stuff
end

Deeper example

function max(num1, num2)
   if  (num1 > num2) then 
       return num1; 
   else 
       return num2; 
   end
end  

-- invoke :  print("The max: ",max(10,4))

Ternary operator in LUA

You might have noticed we could drastically simplify the above function by using a ternary operator. Unfortunately there is no ternary operator in LUA.