Typed Lua · 36 / 69
Describe map values
YOUR TASK
Make this happen
A map annotation constrains each value while allowing different string keys. Build a map of numeric stock levels.
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.stock = function(): { [string]: number }
return { paper = "12", ink = 3 }
end
lesson.test.lua
local t = require("test")
local subject = require("cococo.subject")
t.it("numeric stock", function()
local s = subject.load()
t.expect(s.stock().paper):eq(12)
end)