Created
May 21, 2020 22:05
-
-
Save Corecii/91e9062fdb7ea4276f91581af79b08b1 to your computer and use it in GitHub Desktop.
Roblox TS Try/Catch/Finally Example
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
-- Compiled with roblox-ts v0.4.0 | |
local TS = require(game:GetService("ReplicatedStorage"):WaitForChild("rbxts_include"):WaitForChild("RuntimeLib")) | |
local function example() | |
while true do | |
local _0, _1 = TS.try(function() | |
return TS.TRY_RETURN, {} | |
end, function(err) | |
return TS.TRY_CONTINUE | |
end, function() | |
return TS.TRY_BREAK | |
end) | |
if _0 == TS.TRY_RETURN then | |
return unpack(_1) | |
elseif _0 == TS.TRY_BREAK then | |
break | |
elseif _0 then | |
continue | |
end | |
end | |
end |
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 example() { | |
while (true) { | |
try { | |
return; | |
} catch(err) { | |
continue; | |
} finally { | |
break; | |
} | |
} | |
} | |
export {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment