I want to know is return false / return true different, And if it was different please tell me how its work
COMMUNITY QUESTION
Is return false / return true Different?
2 answers
It is different!
Remember that "false" and "true" are boolean values.
--Boolean overview
local myBool = true
if myBool == true then
print("my bool is true!")
else
print("my bool is false!")
end
Experiment with that a little!
On to the "return" part.
Returning is a step in a function which: exits the function, and passes value(s) back to the caller.
So let's try it out with a less than 10 function!
function isLessThanTen(num)
if num < 10 then
return true
else
return false
end
end
print(isLessThanTen(5))
print(isLessThanTen(100))
no its not really different it depends on the conditions its being returned to like
function food()
return true
end
if food then
--eats
end
--or
function food()
return false
end
if not food then
--does not eat
end
2 comments
0
if not food then meaning false and if food then is basically saying if food is true
0
or if food == 1 or if food == 0 (true or false) so its not really different its just based on how you use it in your conditions
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
First print output: true, second one is false
Correct, which means we now have a function that can tell whether o not a number is less than 10! Think of it like a sentence: 5 Is less than ten? 100 Is less than 10?
return (num < 10) also works xD
Correct but that's not the point of what he asked.