ELI5. What does “return” do in programming? I read about it a lot and still dont understand the purpose.

350 views

ELI5. What does “return” do in programming? I read about it a lot and still dont understand the purpose.

In: 0

10 Answers

Anonymous 0 Comments

You can create small pieces of code that we call “function”. Those function take a few input that we call “arguments” or “parameters”. They execute whenever they are meant to do… and usually return an output we call “result”.

An example of function is “distance”. It takes two coordinates as input and compute the distance between those coordinates and returns said distance.

So that does the return do in programming? It terminate the function it’s in, and takes an optional argument which is the return value of the function.

You are viewing 1 out of 10 answers, click here to view all answers.