How to use TouchPhase.Ended?

Seems like a really a silly question but shockingly, I’m struggling quite a bit. I’ve been able to implement TouchPhase.Began and TouchPhase.Moved but I’m not sure how to use TouchPhase.Ended.
The following code shows how I’m currently testing for it.

 else if (Input.GetTouch(0).phase == TouchPhase.Ended)
            {
                Debug.Log("IT HAS ENDED");
            }

This part of my function never gets called and I assume it’s because when a touch ends there’s no Input. This might be relevant but this code is located in Update().

I do appreciate any and all comments so thank you for reading through and I hope you can help me.
Edit: nvm, turns out i was nesting it incorrectly.

You can use the phase attribute to register the positions.

Touch touch = Input.GetTouch(0);
if (touch.phase == TouchPhase.Began)
{
    //Register the initial position
}
else if (touch.phase == TouchPhase.Moved)
{
    //Move things using deltaPosition or something else
}
else if (touch.phase == TouchPhase.Ended)
{
    //Register the final position and check if the distance is enough to consider a swipe.
}

You can also register the initial and final time, so if the time between the start and the end of the touch is too little, you don’t consider it a swipe.

I hope this helps!