Confuse about early Return , Structure Of An FString

Hello!
May I ask about the class early return, what is the purpose of using return; in an if? My understanding is, its run the result of the things inside the " if " earlier then the if that don’t have a return; ?
if so , how does it help to test the program? or is it the purpose of early return?

Also, are the C++ have things like a time line? which for example I have two function I want to run, A & B, , If I put A above B in the program , A will run first or The both run simultaneously?

Another question is the "An FString is a TArray of TCHAR "
I am not sure if I understand it, So for a word Cakes, It is a 5 characters (or 4 ? because start from zero? and also plus the \0 thing which is another thing i am not sure what it is )
So Cakes is 5 FString which is 1 array of tchar? or what is it?

early return will simply stop the function so everything that is under the return does not get run.

void ExambleFunction()
{
  varibale = 1;
  return;
  variable = 2;
}

In this code variable = 2 will not run.

If you put function A before function B in the code the function A will run first.

While the “return;” purpose is as Mikapo states, you could write the code differently so it doesn’t use the return. Mikapo’s example doesn’t exactly show the use all that well though. You could use it at the very top of a function to block something from doing anything in it or you can use it to return from a function early in the middle of a function. eg if (notReady) return; or if (busyDoingSomething) return; or if (something != null) return;, or if (something == null) return; etc.

It is something you will see use for as you get used to coding if you keep it in mind.

Thank you for the answer !! :hugs: This return; concept stuck me for half day , I am Kinda stupid :rofl:

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms