Is disjoint union of continuous function continuous too? So we suppose that $X$ is disjoint union of the collection
$$
\mathfrak{X}:=\{X_i:i\in I\}
$$
so that I ask if $f_i$ is for any $i\in I$ a continuous function -with respect the subspace toplogy- from $X_i$ to $Y$ then
$$
f:=\bigcup \limits _{i\in I}f_i
$$
is continuous too. I think that the statement is true when $X_i$ are open because apparently the identity
$$
\begin{align}f^{-1}[V] =f^{-1}[V]\cap X
=f^{-1}[V]\cap \left (\bigcup \limits _{i\in I}X_i\right )=\bigcup \limits _{i\in I}\left (f^{-1}[V]\cap X_i\right )=\bigcup \limits _{i\in I}\left (f_i^{-1}[V]\cap X_i\right )\end{align}
$$
holds, but I am not sure about that.  Moreover, what happens if $X_i$ is not always open?
So could someone help me, please?
 A: The statement is generally false: e.g. the indicator function $\chi _\mathbb{Q}$ of $\mathbb{Q}$ is cotinuous on $\mathbb{Q}$ and $\mathbb{I}$ but it is not continuous on $\mathbb{R}$, which is the disjoint union of $\mathbb{Q}$ and $\mathbb{I}$; moreover, $\chi _\mathbb{Q}$ is continuous in each singleton but it is not cotinuous on $\mathbb{R}$, which is the disjoint union of its singletons, whom are closed, so that the statement is generally false for closed sets too.
However, given $V\in \mathcal{P}(Y)$, we observe that an element $x$ of $\displaystyle \bigcup \limits _{i\in I}\left (f^{-1}[V]\cap X_i\right )$ lies in $X_i$ for any $i\in I$ and is such that $f(x)\in V$ but if $x\in X_i$ then$$f(x)=f_i(x)\in V,$$so that $x$ lies in $\displaystyle \bigcup \limits _{i\in I}\left (f_i^{-1}[V]\cap X_i\right )$; conversely, if $x$ lies in  $\displaystyle \bigcup \limits _{i\in I}\left (f_i^{-1}[V]\cap X_i\right )$, then $x$ lies in $f_i^{-1}[V]\cap X_i$ for any $i\in I$, that is, $x$ lies in $X_i$, and in particular$$f(x)=f_i(x)\in V,$$so that $x$ lies in $f_i^{-1}[V]\cap X_i$, that is, in $\displaystyle \bigcup \limits _{i\in I}\left  (f^{-1}[V]\cap X_i\right )$. So we conclude that
$$
f^{-1}[V]
=f^{-1}[V]\cap X=f^{-1}[V]\cap \left (\bigcup \limits _{i\in I}X_i\right ) =\\
\bigcup \limits _{i\in I}\left (f^{-1}[V]\cap X_i\right ) 
=\bigcup \limits _{i\in I}\left (f_i^{-1}[V]\cap X_i\right ) 
=\bigcup \limits _{i\in I}f_i^{-1}[V]
$$
Now, if $X_i$ is open, then by continuity of $f_i$ surely $f^{-1}_i[V]$ is open in $X$ when $V$ is open in $Y$, so that as the union of open sets is always open, then by the last identity $f^{-1}[V]$ is open in $X$ and so $f$ is continuous; moreover, if $X_i$ is closed, then by continuity of $f_i$ surely $f^{-1}[V]$ is closed in $X$ when $V$ is closed in $Y$ so that as the finite union of closed set is closed, then by the last identity $f^{-1}[V]$ is closed, and so $f$ is continuous.
However, we observe that a similar result holds also when $X_i$ are not disjoint as this relevat result show.

Lemma: Pasting Lemma
If $\varphi$ is a function from a space $X$ to a space $Y$ which is continuous on the sets of an open cover $\mathcal{A}$, then it is globally continuous.
Proof: We observe that for any $V\in\mathcal P(Y)$ the identity
$$
\varphi ^{-1}[V]=\varphi ^{-1}[V]\cap X=\varphi ^{-1}[V]\cap \left (\bigcup \limits _{A\in\mathcal{A}}A\right )=\bigcup \limits _{A\in\mathcal{A}}\left (\varphi ^{-1}[V]\cap A\right )=\bigcup \limits _{A\in\mathcal{A}}\left (\varphi \upharpoonright _A\right )^{-1}[V]
$$
Now by assumption $\left (\varphi \upharpoonright _A\right )^{-1}[V]$ is open in $A$, but $A$ is open in $X$, hence $\left (\varphi \upharpoonright _A\right )^{-1}[V]$ is open in $X$ and thus as the union of open sets is always open then by the above identity we conclude that $f^{-1}[V]$ is open in $X$, and so $f$ is continuous.

Moreover an analogous result holds if we replace $\mathcal{A}$ with a closed and finite cover $\mathcal{C}$.
So clearly the function $f$ in the question satisfies the hypotheses of the last lemma, so that we conclude that the problem can be solved directely using the Pasting Lemma.
