General approach to connectedness proofs, with specific example Connectedness proofs have given me trouble for far too long.  Does anyone have good insights on how to go about proving a set is connected?  I know that is a broad question, any insight at all would be helpful.
  I have provided a specific question below that can be used to elaborate on, one that seems pretty simple, yet I haven't had any luck.
Let $A,B$ be two closed subsets of $\mathbb{R^n}$ such that $A \cup B$ and $A \cap B$ are connected. Prove that $A$ is connected.

Some thoughts I've had:
Start by assuming that $A$ is not connected.  Then $A = B \cup C$ where $B$ and $C$ are disjoint nonempty open sets.  From here, proofs usually consider an element $b \in B$ and $c \in C,$ construct a few supplementary sets which then are used to show that a contradiction (usually $B$ or $C$ must be empty or non-disjoint).  I've tried creating such supplementary sets, but haven't had any luck.
 A: There is a little lemma which is very useful when talking about connectedness.

Let $X$ be a topological space, and $\mathcal{D}:=\{0,1\}$ with the discrete topology.
Then, $X$ is connected if and only if every continuous map $f:X \to \mathcal{D}$ is constant.

It will be a good exercise to try and prove this.
This lemma is very helpful in proving basic facts about connectedness. For example, one can prove that arcwise connectedness implies connectedness, product of connected sets is connected, closure of connected sets is connected, union of connected sets with a point in common is connected etc.
In particular, one can prove your example.
For that, consider a continuous map $f: A \to \mathcal{D}$. Note that the restriction $f|_{A \cap B}: A \cap B \to \mathcal{D}$ is continuous. Since $A \cap B$ is assumed to be connected, this restriction is constant (let's call the constant value $c$). Therefore, the map $\widetilde{f}: A \cup B \to \mathcal{D}$ defined by $\widetilde{f}(x)=f(x)$ if $x \in A$, and $\widetilde{f}(x)=c$ if $x \in B$ is continuous by the pasting lemma (here we use that $A,B$ are closed).  Since $A \cup B$ is connected, $\widetilde{f}$ is constant. Therefore, $f$ is constant.
