Does comparing two GameObjects with "==" works?

I have an in-game phone and need it to change between screens, so I made a property that enables the given screen and disable others:

[SerializeField]
private AppScreen InitialScreen;
private AppScreen activeScreen;
public AppScreen ActiveScreen
{
    get => activeScreen;
    set
    {
        activeScreen = value;
        activeScreen.transform.SetAsLastSibling();
        foreach (Transform screen in transform)
        {
            Debug.Log($"({screen.name} == {activeScreen.name}) = {screen == activeScreen}");
            screen.gameObject.SetActive(screen == activeScreen);
        }
    }
}

void Start()
{
    ActiveScreen = InitialScreen;
}

The class has an Initial screen that is activated in the Start() method. This screen and another are the only children of this class.

That foreach is used to iterate over all screens and disable the screen if it isn’t the active one.

But instead it deactivates both screens, so I made a debug, and it looks kinda funny:
207579-sem-titulo.png

My question is: Why this happens and how could I fix that? Thanks

Yes, == works to compare game objects.

However, the issue you’re experiencing is using == to compare Transforms to AppScreens. I.e., comparing two different types of components (which always returns false, ignoring cases of polymorphism).

What you probably meant to do is compare their game objects ( screen.gameObject == activeScreen.gameObject ).