#i can not understand returning bro
1 messages · Page 1 of 1 (latest)
it returns something
actually??
thanks bro
basically it returns something within a scope 👍
nah fr
matter fact im finna jus skip it and learn it later
not getting stuck
ok fine
say you have a function
local function add(x,y)
in this function
you add 2 numbers
basically x + y
so smth like this
local function add(x,y)
local z = x + y
return z
end
if we do
local result = add(3,2)
we get the result cuz we returned it
is that clear enough
@desert torrent
;compile lua ```lua
function GoToStore()
foodBasket = {"apple","banana"}
return foodBasket -- return with the food
end
function IsTheFridgeEmpty()
return true -- because it's always empty somehow
end
function EatFood(foods)
print("start eating;")
for k,v in pairs(foods) do print("nommed ",v) end
end
hungry=true
if hungry and IsTheFridgeEmpty() then -- checking if the fridge is empty is going to the fridge and returning with knowing whether or not the fridge is empty
food=GoToStore() -- the store returns food
EatFood(food)
end
start eating;
nommed apple
nommed banana
lowkey
ill probably pick it up later on
or is it something super important
that i gotta learn immediatly