Skip to content

Instantly share code, notes, and snippets.

@GabeStah
Created March 2, 2015 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GabeStah/5cb1b077a5c48ca9db05 to your computer and use it in GitHub Desktop.
Save GabeStah/5cb1b077a5c48ca9db05 to your computer and use it in GitHub Desktop.
-- EXAMPLE 1
local a = 123
local b = 456
local c = 789
local d = c and a or 'missing'
print(d)
-- OUTPUT: 123
---------------
-- EXAMPLE 2
local a = 123
local b = 456
local c
local d = c and a or 'missing'
print(d)
-- OUTPUT: missing
---------------
---------------
-- EXAMPLE 3
local a
local b = 456
local c
local d = c and a or 'missing'
print(d)
-- OUTPUT: nil
---------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment