connected sets on metric space Given a metric space $(Z,d)$ and two closed subsets $X,Y \subset Z$. 
Let $X$, $\, X \cup Y$ and $X \cap Y$ be connected. 
How can I show that $Y$ is connected?
 A: Let $f:Y\to \{0,1\}$ be continuous. Then $f|_{X\cap Y}$ must also be continuous, and hence constant. Assume WLOG that $f(x)=0$ for all $x\in X\cap Y$.
Define $\hat{f}:X\cup Y\to \{0,1\}$ by $\hat{f}(x)=0$ for $x\in X$, and $\hat{f}|_{Y}=f$. This is clearly well defined, and continuous by the gluing lemma. Thus it must be constant, so $f$ must be constant and therefore the result follows.
Note that this proof never uses the fact that $Z$ is metric, only topological, and that $X$ is connected. We do use the fact that $X$ and $Y$ are closed. Do you see where?
A: Let $Y = O_2 \sqcup O_2$, with $O_1, O_2$ open in $Y$. 
Then $X\cap Y = X \cap O_1 \sqcup X \cap O_2$ with $X \cap O_i$ open in $X$ for $i\in\{1,2\}$. 
But $X \cap Y$ is connected, hence $O_1 = ∅ \lor O_2 = ∅$.
Edit:
But $X \cap Y$ is connected, hence $X \cap O_1 = ∅ \lor X \cap O_2 = ∅$.
Without loss of generality let's assume $X \cap O_1 = ∅$.
We then have $X \cup Y = O_1 \sqcup (X \cup O_2)$.
But $X \cup Y$ is connected, therefore $O_1 = \emptyset$ or $O_2= \emptyset \, \land\, X = \emptyset$. 
Hence $Y$ is connected.
