Pasting Lemma/Pair of Continuous Mappings on Closed Sets

Theorem
Let $X$ and $Y$ be topological spaces.

Let $A$ and $B$ be closed in $X$.

Let $f: A \to Y$ and $g: B \to Y$ be continuous mappings that agree on $A \cap B$.

Let $f \cup g$ be the union of the mappings $f$ and $g$:


 * $\forall x \in A \cup B: \map {f \cup g} x = \begin {cases} \map f x & : x \in A \\ \map g x & : x \in B \end {cases}$

Then the mapping $f \cup g : A \cup B \to Y$ is continuous.