Yes, GetWorld() is used to ensure that the game world exists. To use this type of coding for other classes you just need to remember to add an include statement for the class that you want to access and then create a variable or pointer of the class type. For more examples on how code is used in UE4 I would suggest checking out the programming tutorials: