#explain what "return" does in scratch terms
1 messages · Page 1 of 1 (latest)
What
i dont understand the difference the "return" makes
Normal function wouldn't set variable
To anything
okay i think ill just remember to always use it in a function without fully knowing what it does
update i think i understand now ```local function add(num1, num2)
local result = num1 + num2
return result
end
local sum = add(10, 10)
print(sum)```
if you have a function now you want to seperate code from other to make it more readable or scalable
but if you need a value or similar then you can use the functions to get these
normally functions just do something to values and thats it, if you add a return statement you can get the values and store it somewhere for future use
I love the thinking
You will make yourself a great programmer
return returns the value