Continuity based on restricted continuity of two subsets 
Let $X=A\cup B$, where $A,B$ are subspaces of $X$. Let $f:X\rightarrow Y$; suppose that the restricted functions $f\mid A:A\rightarrow Y$ and $f\mid B:B\rightarrow Y$ are continuous. Show that if both $A$ and $B$ are closed in $X$, then $f$ is continuous.

$f\mid A$ continuous means that for any open subset $V$ of $Y$, the subset $(f\mid A)^{-1}(V)=f^{-1}(V)\cap A$ is open in $A$. Similarly, $f^{-1}(V)\cap B$ is open in $B$. 
The meaning of $(f\mid A)^{-1}(V)=f^{-1}(V)\cap A$ open in $A$ is that $f^{-1}(V)\cap A = C\cap A$ for some $C$ open in $X$. What then?
 A: Hint: $f$ is continuous iff $f^{-1}(K)$ is closed for every closed subset $K$ of $Y$.
A: This result can be seen as a special case of the following lemma, which generalizes the gluing property.

Lemma: Assume that $X=A\cup B$ and $A\setminus B\subseteq\text{int}A,\ B\setminus A\subseteq\text{int}B$. Then $f:X\to Y$ is continuous if the restrictions $f|_A$ and $f|_B$ are continuous.

Proof: Let $U$ be a subset of $X$ that is open in $A$ and in $B$, i.e. there are open sets $U_A,U_B$ such that $U\cap A=U_A\cap A$ and $U\cap B=U_B\cap B$. Then $(U_A\cap\text{int}A)\cup(U_B\cap\text{int}B)\cup(U_A\cap U_B)$ is open. But this set is also equal to $U$. Thus $U$ is open.
Now, if $f:X\to Y$ has continuous restrictions $f|_A$ and $f|_B$ and $U\subset Y$ is open, then $f^{-1}(U)$ is open in $A$ and in $B$, hence open in $X.$ $\square$
This lemma can be found in Brown's Topology and Groupoids, p.37, though the proof there is a bit different.
Now, if $A$ and $B$ are closed, then $A\setminus B\subseteq X\setminus B\subseteq \text{int}A$ and $B\setminus A\subseteq X\setminus A\subseteq \text{int}B$, so we can apply the lemma.
