Menu
CoddyTech
Course

Luau for Ruby Developers

Bring Ruby experience to Luau: tables, lexical closures, typed signatures, runtime contracts and metatable objects. Build a stock ledger and port two Ruby reference programs.

Ruby and Luau side by side

The same program in Ruby and in Luau, from the lessons of this course.

  1. Print and Comment

    Ruby puts converts values to text and normally terminates each printed line. Luau print inserts tabs between arguments and adds one final newline. Build one exact string with .. when needed and return results to the task driver. Luau comments use -- rather…

    Ruby
    1name="Ada"; puts "Hi "+name+" !"
    Luau
    1local name = "Ada"2print(`Hi, {name}`)
  2. None and Missing Fields

    A Ruby Hash can retain a key mapped to nil, and key? distinguishes presence from a missing key. Luau nil removes the table association. An optional annotation cannot preserve a nil-valued entry. Use a tagged record or separate presence flag when both states…

    Ruby
    1values={"x"=>nil}; puts values.key?("x")
    Luau
    1local d = {x = nil}2print(d.x == nil)
  3. Ranges to Numeric for

    Ruby .. includes the final range value while ... excludes it, and iterators choose how ranges are traversed. Luau numeric for includes its bound and needs a negative step for descending traversal. Translate the values actually visited and preserve empty-range…

    Ruby
    1total=0;(2...5).each{|n|total+=n};puts total
    Luau
    1local total = 02for i = 1, 3 do total = total + i end3print(total)
  4. Functions and Returns

    Ruby methods have runtime arity rules and objects are passed through references; reassigning a parameter does not rebind the caller. Luau scalar rebinding stays local and table fields permit shared mutation. Typed signatures describe intent but untrusted…

    Ruby
    1def hours(total);total/60;end;puts hours(125)
    Luau
    1local function twice(x: number): number return x * 2 end2print(twice(4))
  5. Lists as Dense Tables

    Ruby Arrays grow dynamically and delete_at shifts later elements, with zero-based and negative indexing conventions. Luau dense tables begin at one and table.remove shifts entries. Assigning nil creates a hole; Luau negative keys do not automatically mean…

    Ruby
    1values=[10,20,30];values.delete_at(1);puts values.join(",")
    Luau
    1local a = {"a", "b", "c"}2table.remove(a, 2)3print(table.concat(a, ","))
  6. Sorting and Comparators

    Ruby sort returns a new array while sort! mutates, and comparison blocks use a three-way numeric result. Luau table.sort mutates and expects a Boolean strict ordering predicate. Numeric differences are wrong because zero is truthy. Copy first when the…

    Ruby
    1a=[10,2];b=a.sort;puts a.join(",");puts b.join(",")
    Luau
    1local a={3,1,2}2table.sort(a)3print(a[1])

Syllabus

10 chapters48 lessons1 project48 challenges99 quiz questions

Final Ruby Ports

2 lessons

More courses for Ruby developers

Learn Luau from another language

Frequently asked questions

Who is Luau for Ruby Developers for?

For people who already write Ruby and want to learn Luau. Each lesson starts from Ruby 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 Ruby basics: variables, conditions, loops, functions and collections.

How many lessons does Luau for Ruby Developers have?

Luau for Ruby Developers contains 48 interactive lessons you can complete at your own pace.

What does Luau for Ruby 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 Ruby 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 Ruby Developers for free

Get started