#i can not understand returning bro

1 messages · Page 1 of 1 (latest)

desert torrent
#

can someone give me a good explanation??

manic osprey
#

it returns something

silk spruce
desert torrent
exotic pilot
#

basically it returns something within a scope 👍

desert torrent
#

matter fact im finna jus skip it and learn it later

#

not getting stuck

exotic pilot
#

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

desert torrent
#

ion understand it

#

i can look at the script i just dont know what it means bro

dreamy gust
# desert torrent i can look at the script i just dont know what it means bro

;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

little wraithBOT
#
Program Output
start eating;
nommed apple
nommed banana

desert torrent
#

ill probably pick it up later on

#

or is it something super important

#

that i gotta learn immediatly

dreamy gust
#

it's fairly important but you'll pick it up as you go. just think of it as the natural language meaning of return

#

you go somewhere, and then return back, usually with a something you went to that place for.

desert torrent
#

yea i jus started coding a few days ago

#

learning