Question on the purpose of currenLines.removeAll()?

Hi guys,
I am wondering why do we need to currentLines.removeAll() here?
From what i understand, every time touchesEnded, we remove the current lines, so basically currentLines will become empty dictionary.
Thanks.

func doubleTap(_ gestureRecognizer: UIGestureRecognizer) {
    print("Recognized double tap")
    selectedLineIndex = nil
    currentLines.removeAll()
    finishedLine.removeAll()
    setNeedsDisplay()
}

func longPress(_ gestureRecognizer: UIGestureRecognizer) {
    print("Long press is recognized")
    
    if gestureRecognizer.state == .began {
        let point = gestureRecognizer.location(in: self)
        selectedLineIndex = indexOfLine(at: point)
        
        if selectedLineIndex != nil {
           currentLines.removeAll()
        }
    } else if gestureRecognizer.state == .ended {
        selectedLineIndex = nil
    }
    
    setNeedsDisplay()
        
}

At the point of the book when we were asked to write out func doubleTap(_ gestureRecognizer: UIGestureRecognizer), it was still possible for a red dot to appear as part of the double-tap gesture since this gesture recognizer wouldn’t call touchesEnd(_:with:) (see the debug output) and thus the touchesBegan(_:with:) call still added a Line object to currentLines. The book brings this up as a point, which is why they introduced the delayTouchesBegan property.

For the longPress(_:) call, I presume that it deletes any lines that might have been drawn if touchesBegan(_:with:) was called. The long press recognizer didn’t have its delaysTouchesBegan property set unlike the single and double tap gesture recognizers. You should be able to check if touchesBegan(_:with:) is called during a long press by looking at the console for the print statement being invoked.