Menu
CoddyTech

Print and Comment

Lesson 2 of 48 in Coddy's Luau for Dart Developers course.

Dart interpolation embeds values into a string passed to print. Luau print accepts multiple arguments but separates them with tabs; concatenate with .. when one exact string is required. Luau chunks run directly without a Dart main function, and comments use --.

Dart comparison


void main() {
print("Hi" + ", Ada");
}

Luau behavior

Luau keeps print and -- comments. Concatenation uses .., while backtick strings interpolate expressions in braces. Construct one string when the output contract specifies spacing; print with multiple arguments inserts separators.

local name = "Ada"
print(`Hi, {name}`)

Expected Luau output:

Hi, Ada
challenge icon

Challenge

Easy

Return Hello, followed by the first input line exactly, or an empty name when input is absent. Spaces and punctuation are significant.

Edit app.luau. The visible locked main.luau reads stdin into a sequence of lines, calls app.run(lines), and prints its returned value with one final newline. Do not print diagnostics or change the module names. Empty input gives an empty sequence. All numeric inputs are small enough to avoid overflow.

Try it yourself

local app = require("./app")
local lines = {}
for line in io.lines() do lines[#lines + 1] = line end
print(app.run(lines))
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Luau for Dart Developers

Practice on your own: Online Luau compiler