Skip to content

Do

When used as a statement, do works just like it does in Lua.

do
var = "hello"
print var
print var -- nil here

YueScript’s do can also be used an expression. Allowing you to combine multiple lines into one. The result of the do expression is the last statement in its body.

counter = do
i = 0
->
i += 1
i
print counter!
print counter!
tbl = {
key: do
print "assigning key!"
1234
}

do expressions also support using break to interrupt control flow and return multiple values early:

status, value = do
n = 12
if n > 10
break "large", n
break "small", n

YueScriptCompiler

Loading compiler…