d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Not Sure I Understand Return Statements
12Next
Add Reply New Topic New Poll
Member
Posts: 34,575
Joined: Mar 25 2009
Gold: 12,633.00
Apr 27 2016 07:48pm
I get how to use them to return a value.... i understand what it does
for instance return a; would return value of a variable..

but ehhh, I'm not sure what else it's used for, isn't it used to exit a method?not sure....
for instance using return alone without any return data/value


Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Apr 27 2016 10:25pm
It is used for returning from a function, there is no other meaning to it.

If you want to get literal return is an alias for the ret instruction in assembly which pops the return address off the stack and then jumps back to that address to resume flow from where the address left off.
Member
Posts: 34,575
Joined: Mar 25 2009
Gold: 12,633.00
Apr 27 2016 11:21pm
Returning from a function... meaning method i'm assuming...also does that mean ur using a return statement inside a method to exit the method? Could you give me an example?
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Apr 27 2016 11:22pm
Quote (ferf @ Apr 28 2016 01:21am)
Returning from a function... meaning method i'm assuming...also does that mean ur using a return statement inside a method to exit the method? Could you give me an example?


http://stackoverflow.com/questions/744676/what-does-the-return-keyword-do-in-a-void-method-in-java
Member
Posts: 34,575
Joined: Mar 25 2009
Gold: 12,633.00
Apr 27 2016 11:24pm
Quote (carteblanche @ Apr 28 2016 01:22am)


Reading that i still don't understand, i mean does it exit the method? Or does it restart the method and not execute anything after return?
I'm hoping Abduct can elaborate on my first reponse to him....

This post was edited by ferf on Apr 27 2016 11:25pm
Member
Posts: 34,575
Joined: Mar 25 2009
Gold: 12,633.00
Apr 27 2016 11:27pm
I mean if it just exits the method when u type return, without executing the rest of stuff in method, how is that different from break?
There's something i'm not understanding i'm guessing
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Apr 27 2016 11:28pm
Quote (ferf @ Apr 28 2016 01:27am)
I mean if it just exits the method when u type return, without executing the rest of stuff in method, how is that different from break?
There's something i'm not understanding i'm guessing


i explained that to you in your break thread.
Member
Posts: 34,575
Joined: Mar 25 2009
Gold: 12,633.00
Apr 27 2016 11:31pm
Quote (carteblanche @ Apr 28 2016 01:28am)
i explained that to you in your break thread.


Just looked there... didn't see anything about return statements...........
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Apr 27 2016 11:33pm
Quote (ferf @ Apr 28 2016 01:31am)
Just looked there... didn't see anything about return statements...........


your other break thread

http://forums.d2jsp.org/topic.php?t=74195374&f=124&o=0
Member
Posts: 34,575
Joined: Mar 25 2009
Gold: 12,633.00
Apr 27 2016 11:35pm
I understand it now thanks
Go Back To Programming & Development Topic List
12Next
Add Reply New Topic New Poll