1,004
edits
m (order change for correct questions) |
m (revized quiz) |
||
Line 151:
|type="()"}
- a = 4
|| This defines <code>a</code> globally - not locally.
- do a = 4 end
|| This defines <code>a</code> globally (not locally), and within a scope block.
+ local a = 4
- local a = "4"
|| This defines <code>a</code> locally, but as "4" (a string), not 4 (a number).
{Defining variables in the local scope is always preferred
Line 159 ⟶ 162:
+ TRUE
- FALSE
|| Always defining variables in the local scope is less memory intensive and makes you less prone to mistakes
{What will the following code print? <syntaxhighlight lang="lua" line="1">
local hello = "Hello world!"
print(hello)
</syntaxhighlight>
|type="()"}
- hello
+ Hello world!
- "Hello world!"
- 'hello'
{Consider the following code: <syntaxhighlight lang="lua" line="1">
local b = 2
local
do
b = 5
print(
end
Line 172 ⟶ 187:
</syntaxhighlight>
The code will print out:
|type="()" coef="2"}
- 5, then 2
|| You seem to have mixed up the variables.
- 2, then 3
|| You seem to have mixed up the variables.
- 3, then 5
|| <code>b</code> is equal to 5 only in the scope block; not outside of it.
+ 3, then 2
Line 194 ⟶ 212:
If the output of the code was '''54''' and '''24'''.
|type="{}" coef="4"}
First missing line: { print(c) }
Second missing line: { c=24|s=24|local c = 24|local c=24|local s = 24|local s=24 }
|