0

what does "return" in void name()?

I cant understand. Please explain me, what difference betweein void with "return" and without

26th Aug 2017, 12:12 PM
Night Ranger
Night Ranger - avatar
3 Respuestas
+ 2
return in void has no meaning, because void returns nothing. Some people use return to stop the code execution in a method (maybe because a condition was false).
26th Aug 2017, 12:47 PM
StoneSmasher
StoneSmasher - avatar
+ 1
in void return does an error...😄😄😄
26th Aug 2017, 3:46 PM
Dragon Slayer Xavier
Dragon Slayer Xavier - avatar
0
@Amrit Mahendra Joseph Yes, you are not allowed to return an object, but return nothing is ok. return; // is ok return (something); // throws error
26th Aug 2017, 4:52 PM
StoneSmasher
StoneSmasher - avatar