About return
#9

I use them because it will end that section of code. I don't know the fancy words for it but it stops the code where it's at. At least that's my understanding of it. Let me show you...

pawn Код:
public Function(blah)
{
  if(blah == 1)
  {
     //Some code
  }
  if(blah == 2)
  {
     //Some code
  }
  return 1;
}
Now if blah equals 1, it's going to go in there and execute that code. After that, if there's no return, it will jump out and check if blah equals 2. Well this is unnecessary because we already saw that it equaled 1. If there's a return in there, it will stop after it sees it's at 1. You could return whatever number you wanted to. It just depends on the code. If you had some more code at the bottom of those if statements, then you wouldn't want to have a return in them.
Reply


Messages In This Thread
About return - by UsaBoy91 - 15.05.2010, 17:47
Re: About return - by juice.j - 15.05.2010, 17:53
Re: About return - by Torran - 15.05.2010, 17:55
Re: About return - by UsaBoy91 - 15.05.2010, 18:00
Re: About return - by UsaBoy91 - 15.05.2010, 18:54
Re: About return - by ¤Adas¤ - 15.05.2010, 18:58
Re: About return - by UsaBoy91 - 15.05.2010, 18:58
Re: About return - by Sergei - 15.05.2010, 19:01
Re: About return - by Backwardsman97 - 15.05.2010, 19:03
Re: About return - by MafiaGuy™ - 16.05.2010, 12:02

Forum Jump:


Users browsing this thread: 1 Guest(s)