arrow_back Back to Notebook
lua
lua
January 10, 2019

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.

Thanks for reading!

John Wiseman

Full-Stack Software Engineer building scalable digital solutions. specializing in modern web technologies and mission-critical systems.

© 2026 Wiseman Systems Pty. Ltd.

Navigation

Start a Conversation

Ready to discuss your next project? Let's build something extraordinary together.

Get in Touch