My real analysis textbook says that the set $$[0,1] \cup (2,3]$$ has maximum and minimum, but it is not compact. At the same time, the Heine-Borel Theorem says that
A subset $S$ of $\mathbb R$ is compact iff $S$ is closed and bounded.
To my inexperienced eyes, the set $[0,1] \cup (2,3]$ is bounded, hence its maximum and minimum, and is also closed $-$ therefore according to the theorem it should be compact. Please let me know why I get so wrong $-$ thank you.