In this question:
universal property in quotient topology
I saw the following theorem:
Let $X$ be a topological space and $\sim$ an equivalence relation on $X$. Let $\pi: X\to X/{\sim}$ be the canonical projection. If $g : X → Z$ is a continuous map such that $a \sim b$ implies $g(a) = g(b)$ for all $a$ and $b$ in $X$, then there exists a unique continuous map $f : X/{\sim} → Z$ such that $g = f ∘ \pi$.
I was wondering how one would prove this.