Recap: Introduction to Luau
Part of the Introduction To Luau section of Coddy's Lua journey. Lesson 5 of 80.
Challenge
MediumStore a number id, then turn it into a string name.
- Declare
local userId: number = 12345andlocal username: string = "john_doe". - Add
username = tostring(userId): astringvariable only takes strings. - Keep the two
printlines at the bottom.
Press Run Code: the output shows 12345 twice.
Try it yourself
-- 1) declare userId and username with their types
-- 2) put the id into username with tostring()
-- Print the results
print(userId)
print(username)
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 ValuesDefaults for BooleansVariadic FunctionsDefining Function TypesRecap: Typed Functions2Core Types
Number, String and BooleanThe '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 TablesReading a GridBuilding a Gridtable.unpackRecap: Arrays and MapsPractice on your own: Online Luau compiler