Luau for Swift Developers
Transfer Swift value types, collections and protocols to Luau tables, closures and typed signatures. Practice runtime validation, relative modules and metatable objects, build a stock ledger and port two Swift programs.
Swift and Luau side by side
The same program in Swift and in Luau, from the lessons of this course.
Print and Comment
Swift print accepts a separator and terminator and interpolation converts values into text. Luau print inserts tabs between arguments and a final newline. Build one string with .. when exact formatting matters, and return it to the locked driver. Luau…
Swift1let name = "Ada"2print("Hi, \(name)")Luau1local name = "Ada"2print(`Hi, {name}`)Missing Fields and Optionals
Swift Optional represents a missing value with nil and distinguishes it from false. Dictionary lookup adds an optional layer, and assigning nil through a dictionary subscript removes its entry. Luau nil likewise removes a table association, but Luau has no…
Swift1var values = ["x": 1]2values["x"] = nil3print(values.count)Luau1local d = {x = nil}2print(d.x == nil)Inclusive Numeric Loops
Swift half-open ranges exclude their upper bound and closed ranges include it. Luau numeric for always includes its limit and accepts an optional step. Translate the values actually visited, and use a negative step for descending traversal. Keep empty-range…
Swift1var total = 02for i in 1..<4 { total += i }3print(total)Luau1local total = 02for i = 1, 3 do total = total + i end3print(total)Functions and Returns
Swift signatures enforce parameter and return types, with inout permitting writeback to caller storage. Luau typed signatures describe intent but this runner does not invoke the analyzer. Numeric rebinding stays local; tables allow shared field mutation…
Swift1func twice(_ n: Int) -> Int { n * 2 }2print(twice(4))Luau1local function twice(x: number): number return x * 2 end2print(twice(4))Lists as Dense Tables
Swift Array is a value type with zero-based indexing and copy-on-write storage. Luau represents dense lists with one-based table keys. table.insert and table.remove shift sequence elements; assigning nil leaves a hole instead. The length operator is reliable…
Swift1var values = [2, 3]2values.append(4)3print(values.count)Luau1local a = {"a", "b", "c"}2table.remove(a, 2)3print(table.concat(a, ","))Sorting and Comparators
Swift sort mutates a collection and sorted returns a new collection; both accept a Boolean ordering predicate. Luau table.sort mutates the sequence and returns no value. Its comparator must report strict ordering. Keep the original table reference, and add a…
Swift1var values = [10, 2, 1]2values.sort(by: <)3print(values.map(String.init).joined(separator: ","))Luau1local a={3,1,2}2table.sort(a)3print(a[1])
Syllabus
10 chapters48 lessons1 project48 challenges99 quiz questionsFirst Luau Programs
6 lessonsValues and Decisions
5 lessonsIteration and Flow
5 lessonsFunctions and Closures
5 lessonsTables as Collections
5 lessonsOrdering, Modules and Errors
5 lessonsObjects and Owned State
5 lessonsComposition and Object Lookup
6 lessonsProject: Stock Ledger
4 lessonsFinal Source Ports
2 lessonsFrequently asked questions
Who is Luau for Swift Developers for?
For people who already write Swift and want to learn Luau. Each lesson starts from Swift you know and shows how Luau does the same thing, so you skip the beginner basics.
Do I need to know Luau already?
No. The course starts with your first Luau program. You need Swift basics: variables, conditions, loops, functions and collections.
How many lessons does Luau for Swift Developers have?
Luau for Swift Developers contains 48 interactive lessons you can complete at your own pace.
What does Luau for Swift Developers cover?
The course is organized into chapters covering: First Luau Programs, Values and Decisions, Iteration and Flow, Functions and Closures, and more.
Is Luau for Swift Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.