VideosMy ProjectsProgramming BlogGallery
  1. Home
  2. Blog
  3. All about functions in LUA
Programming Blog

Atom/RSS Feed

lua

All about functions in LUA

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.

Join my mailing list