rusty-luau/examples/russianRoullete.luau

21 lines
383 B
Text
Raw Permalink Normal View History

local result = require("../lib/result")
type Result<T, E> = result.Result<T, E>
local Ok = result.Ok
local Err = result.Err
local function canError(): Result<number, string>
2024-07-15 14:16:36 +01:00
if math.round(math.random()) == 1 then
return Err("you DIED")
end
2024-07-15 14:16:36 +01:00
return Ok(69)
end
function main()
2024-07-15 14:16:36 +01:00
local val = canError():unwrap()
2024-07-15 14:16:36 +01:00
print("got value: ", val)
end
return main()