22 lines
586 B
Text
22 lines
586 B
Text
local function get_day_no(day)
|
|
-- Throws an error if day is invalid.
|
|
return switch day:lower() do
|
|
case "monday" -> 1
|
|
case "tuesday" -> 2
|
|
case "wednesday" -> 3
|
|
case "thursday" -> 4
|
|
case "friday" -> 5
|
|
case "saturday" -> 6
|
|
case "sunday" -> 7
|
|
default -> error($"'{day}' is not a valid day in English.")
|
|
end
|
|
end
|
|
|
|
for {"thursday", "jeudi"} as day do
|
|
local ok, res = pcall(get_day_no, day)
|
|
if ok then
|
|
print($"'{day}' is day number {res}")
|
|
else
|
|
print(res)
|
|
end
|
|
end
|