Skip to content

Instantly share code, notes, and snippets.

@YellowAfterlife
Created September 17, 2014 11:44
Show Gist options
  • Save YellowAfterlife/c4986e07e314161895fc to your computer and use it in GitHub Desktop.
Save YellowAfterlife/c4986e07e314161895fc to your computer and use it in GitHub Desktop.
function Main_Main.tryNormal()
local r
local try, catch = pcall(function ()
r = "normal"
end);
if (try == false) then
local _ = catch;
r = nil
end
return r
end
function Main_Main.tryCompact()
local r = nil
local try, catch = pcall(function ()
r = "compact"
end);
return r
end
function Main_Main.tryReturn()
local try, catch = pcall(function ()
return "return";
end);
if (try == false) then
local _ = catch;
return nil;
else return catch end
end
function Main_Main.tryReturnCompact()
local try, catch = pcall(function ()
return "returnCompact";
end);
if try then return catch end
return nil
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment