Menu
CoddyTech

Project: The Task Shape

Part of the Introduction To Luau section of Coddy's Lua journey. Lesson 47 of 80.

challenge icon

Challenge

Easy

Start the task manager by giving its list a type.

  1. Above the list, write type Task = {id: number, title: string, done: boolean}.
  2. Annotate the list: local tasks: {Task} = {.
  3. Under -- Try it, add print(tasks[3].done).

Press Run Code: the output shows Learn Luau types, 3 and true.

Try it yourself

-- Add the Task type here
local tasks = {
    {id = 1, title = "Learn Luau types", done = false},
    {id = 2, title = "Build a task manager", done = false},
    {id = 3, title = "Write tests", done = true},
}
-- Try it
print(tasks[1].title)
print(#tasks)

All lessons in Introduction To Luau

Practice on your own: Online Luau compiler