Project: The Task Shape
Part of the Introduction To Luau section of Coddy's Lua journey — lesson 45 of 73.
Challenge
EasyLay the foundation of the task manager.
Define a type alias named Task describing a table with:
idof typenumbertitleof typestringdoneof typeboolean
Create a typed array named tasks of type {Task} containing, in order:
- id
1, title"Learn Luau types", donefalse - id
2, title"Build a task manager", donefalse - id
3, title"Write tests", donetrue
Then print, each on its own line:
- the first task's
id - the first task's
title - the first task's
doneflag - how many tasks there are (use
#)
Try it yourself
-- Write code here
-- 1) define type Task = {id: number, title: string, done: boolean}
-- 2) create tasks: {Task} with the three starter tasks
-- 3) print the first task's id, title and done flag, then the task count
All lessons in Introduction To Luau
1Getting Started with Luau
What Is Luau?Why Use Luau?Your First Luau CodeType Checking & Error ModesRecap: Introduction to Luau4Working with Functions
Typing Params & Return ValuesTyping Anonymous FunctionsFunctions Returning NothingOptional ParametersDefault Parameter ValuesVariadic FunctionsDefining Function TypesRecap: Typed Functions7Project: Typed Task Manager
Project: The Task ShapeFunction to Add a Task2Core Types
Basic Types: num, str, boolThe 'any' Type: Escape HatchThe 'unknown' TypeNil & Optional TypesType Inference in ActionExplicit Type AnnotationsRecap: Core Types Practice5Aliases, Unions, Intersections
Type Aliases for PrimitivesUnion TypesWorking with Union TypesLiteral TypesIntersection TypesCombining Type AliasesRecap: Advanced Type Combos3Typed Tables: Arrays & Maps
Typed ArraysAdding and Reading ElementsWhat is a Map Type?Declaring and Accessing MapsIterating TablesMixed-Shape TablesMulti-dimensional Typed Arraystable.unpack and VarargsRecap: Arrays and Maps