Menu
CoddyTech
Course

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.

  1. 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…

    Swift
    1let name = "Ada"2print("Hi, \(name)")
    Luau
    1local name = "Ada"2print(`Hi, {name}`)
  2. 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…

    Swift
    1var values = ["x": 1]2values["x"] = nil3print(values.count)
    Luau
    1local d = {x = nil}2print(d.x == nil)
  3. 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…

    Swift
    1var total = 02for i in 1..<4 { total += i }3print(total)
    Luau
    1local total = 02for i = 1, 3 do total = total + i end3print(total)
  4. 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…

    Swift
    1func twice(_ n: Int) -> Int { n * 2 }2print(twice(4))
    Luau
    1local function twice(x: number): number return x * 2 end2print(twice(4))
  5. 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…

    Swift
    1var values = [2, 3]2values.append(4)3print(values.count)
    Luau
    1local a = {"a", "b", "c"}2table.remove(a, 2)3print(table.concat(a, ","))
  6. 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…

    Swift
    1var values = [10, 2, 1]2values.sort(by: <)3print(values.map(String.init).joined(separator: ","))
    Luau
    1local a={3,1,2}2table.sort(a)3print(a[1])

Syllabus

10 chapters48 lessons1 project48 challenges99 quiz questions

Final Source Ports

2 lessons

More courses for Swift developers

Learn Luau from another language

Frequently 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.

Coddy programming languages illustration

Start Luau for Swift Developers for free

Get started