Thinking in Lua · 10 / 69
Combine conditions
YOUR TASK
Make this happen
Use and when both conditions must hold. An order may proceed only when it is paid and not cancelled. Lua’s logical operators short-circuit.
Read the cases in
lesson.test.lua, then choose Check solution to see what needs to change.Update
subject.luauntil every test passes. Keep the supplied tests unchanged.
Read the starter and tests
subject.lua
exports.ready = function(paid: boolean, cancelled: boolean): boolean return paid end
lesson.test.lua
local t = require("test")
local subject = require("cococo.subject")
t.it("paid and active", function()
local s = subject.load()
t.expect(s.ready(true, false)):eq(true)
end)
t.it("cancelled wins", function()
local s = subject.load()
t.expect(s.ready(true, true)):eq(false)
end)
t.it("payment required", function()
local s = subject.load()
t.expect(s.ready(false, false)):eq(false)
end)