Why is GetWorld() defined in three seperate places?

I’m new to Unreal Engine, so forgive me if this is a silly question.

I’m trying to call GetWorld(), so under the IWYU paradigm I need to include a header file reference where GetWorld() is defined. There appears to be three places where GetWorld() is defined:

Why is this, what’s the difference between them, and how do I decide which one to use?

The GetWorld() function is from UObject, well any UObject can override this function.

So am I right in saying that the reason GetWorld() can be found in different places, is because these functions override the GetWorld() virtual function defined in UObject, and provide three different methods of returning the same pointer to the world? The methods may be different because they can return that pointer in different ways, but as it’s the same result, it doesn’t really matter which header file I include if the code compiles and works.

GetWorld() return world which that object belongs to, and each object have different sense of it, if it belongs at all to the world. So the override GetWorld().

One of actor main function is to beling to the world (when world gets destroyed all actors goes with it) and one of UWorld function is to keep track of actors.

Components inherently also belongs to world (but AActor keeps track of them not UWorld) because they are part of Actor so it returns world of host actor they are in.

As for why UWorld has it… well i was suppriced myself so i checked the source and find this note:

UWorld* UWorld::GetWorld() const
	// Arg... rather hacky, but it seems conceptually ok because the object passed in should be able to fetch the
	// non-const world it's part of.  That's not a mutable action (normally) on the object, as we haven't changed
	// anything.
	return const_cast<UWorld*>(this);

Note that it just return casted this as kind of expected. Note that those aren ot only function declerting own GetWorld