×
Create a new article
Write your page title here:
We currently have 276 articles on Waste Of Space Wiki. Type your article name above or create one of the articles listed here!



    Waste Of Space Wiki

    Programming/Staging: Difference between revisions

    Content added Content deleted
    m (order change for correct questions)
    m (revized quiz)
    Line 151: Line 151:
    |type="()"}
    |type="()"}
    - a = 4
    - a = 4
    || This defines <code>a</code> globally - not locally.
    - do a = 4 end
    - do a = 4 end
    || This defines <code>a</code> globally (not locally), and within a scope block.
    + local a = 4
    + local a = 4
    - 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
    {Defining variables in the local scope is always preferred
    Line 159: Line 162:
    + TRUE
    + TRUE
    - FALSE
    - 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">
    {Consider the following code: <syntaxhighlight lang="lua" line="1">
    local b = 2
    local b = 2
    local x = 3
    local p = 3


    do
    do
    b = 5
    b = 5
    print(x)
    print(p)
    end
    end


    Line 172: Line 187:
    </syntaxhighlight>
    </syntaxhighlight>
    The code will print out:
    The code will print out:
    |type="()"}
    |type="()" coef="2"}
    - 5, then 2
    - 5, then 2
    || You seem to have mixed up the variables.
    - 2, then 3
    - 2, then 3
    || You seem to have mixed up the variables.
    - 3, then 5
    - 3, then 5
    || <code>b</code> is equal to 5 only in the scope block; not outside of it.
    + 3, then 2
    + 3, then 2


    Line 194: Line 212:
    If the output of the code was '''54''' and '''24'''.
    If the output of the code was '''54''' and '''24'''.


    |type="{}"}
    |type="{}" coef="4"}
    First missing line: { print(c) }
    First missing line: { print(c) }
    Second missing line: { c=24|s=24|local c = 24|local c=24|local s = 24|local s=24 }
    Second missing line: { c=24|s=24|local c = 24|local c=24|local s = 24|local s=24 }
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.

    Recent changes

  • 116.111.185.163 • 7 hours ago
  • 116.111.185.163 • 7 hours ago
  • 116.111.185.163 • 7 hours ago
  • 116.111.185.163 • 8 hours ago
  • Cookies help us deliver our services. By using our services, you agree to our use of cookies.