+ 3

What does return mean and what does it do

Can someone please explain return

29th Apr 2017, 2:22 PM
Ayanfe
Ayanfe - avatar
7 Answers
+ 10
return is used for return values after some execution to where the function is called, you can use return 0; to return nothing and yeah if you have some function and with return type int then it will the value which is type integer.
29th Apr 2017, 2:36 PM
Jay Tailor
Jay Tailor - avatar
+ 8
I thought return is just return in c#. the value is optional. this is my understanding and please correct me if I am incorrect When we want to return an int( lets say 5 ). We think of it as return to the place of execution with an "int". not return this "int" to the place of execution
29th Apr 2017, 2:46 PM
jay
jay - avatar
+ 7
"return" :verb: Go back to. --- returns to the place of execution.
29th Apr 2017, 2:32 PM
jay
jay - avatar
+ 7
COMPL3X , Good explanation
29th Apr 2017, 3:23 PM
Jay Tailor
Jay Tailor - avatar
+ 5
return means to give back a value.
29th Apr 2017, 2:33 PM
Complex
Complex - avatar
+ 5
Look at this code: (Rust) fn main() { println("{:?}", say("Hey")); //Calling the say function. Ofcourse, you need to print it, as return only returns a value not print it. } fn say(txt) { txt //Doing this without semicolon means implicit return type in Rust }
29th Apr 2017, 2:38 PM
Complex
Complex - avatar
+ 2
Thanks
29th Apr 2017, 3:56 PM
Ayanfe
Ayanfe - avatar