Created
September 17, 2014 11:44
-
-
Save YellowAfterlife/c4986e07e314161895fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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