Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why won't this work?

Asked by 10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

I'm practicing my returning and functions and printing, but for some reason, when I test it, it doesn't show the values after beef. burgers=854649

function cheese()

    print ("lettuce")
    print ("lettuce")
    print ("lettuce")
    print ("lettuce")
    print ("lettuce")

return "beef" 

end

print (burgers) burgers=cheese print (cheese()) ~~~~~~~~~~~~~~~~~

0
What do you mean the values after beef? It starts printing things at line 17. It prints the value of the variable burgers, then runs through the function cheese and prints the returned beef. What else is it suppose to print? BlackJPI 2658 — 10y
0
Thats the problem. It DIDNT print things after beef. InfernoChaosInfinity 2 — 10y

1 answer

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

Nothing is wrong.

The output is this, correctly:

854649
lettuce
lettuce
lettuce
lettuce
lettuce
beef

Line 18 in the snippet you posted doesn't really matter, since you don't use burgers after that. You can remove it.

burgers = 854649

function cheese()
    print ("lettuce")
    print ("lettuce")
    print ("lettuce")
    print ("lettuce")
    print ("lettuce")
    return "beef" 
end

print(burgers) -- 854649
print( cheese() )
    -- cheese() prints:
        -- lettuce, lettuce, lettuce, lettuce, lettuce
        -- `cheese()`returns "beef"
    -- prints evaluation of `cheese()` which is "beef"
Ad

Answer this question