Is the intersection of a closed set and a compact set always compact?

I am going through Rudin’s Principles of Mathematical Analysis in preparation for the masters exam, and I am seeking clarification on a corollary.

Theorem 2.34 states that compact sets in metric spaces are closed. Theorem 2.35 states that closed subsets of compact spaces are compact. As a corollary, Rudin then states that if $L$ is closed and $K$ is compact, then their intersection $L \cap K$ is compact, citing 2.34 and 2.24(b) (intersections of closed sets are closed) to argue that $L \cap K$ is closed, and then using 2.35 to show that $L \cap K$ is compact as a closed subset of a compact set.

Am I correct in believing that this corollary holds for metric spaces, and not in general topological spaces?

Solutions Collecting From Web of "Is the intersection of a closed set and a compact set always compact?"

In any Hausdorff space compact sets are automatically closed, and so the above argument works as written. It is true that in non-Hausdorff spaces, a compact set
need not be closed.

On the other hand, it is true in general that a closed subset of a compact topological space is compact (whether or not the compact space is Hausdorff);
this is easily proved directly in terms of the open cover characterization of
compact topological spaces.

So if $K$ is compact in an arbitrary topological space (which is just to say
that it is a compact topological space when given its induced topology) and $L$ is closed then $K \cap L$ is a closed subset of
$K$ in its induced topology, and hence is compact with its induced topology,
i.e. is again a compact subset of the ambient topological space (even though
it need not be closed).

Summary: The corollary does hold for arbitrary (not necessarily Hausdorff) topological space, but you need to rewrite the proof slightly.

As usual, nets provide an elegant proof. Let $L$ be closed and $K$ compact. Suppose $(x_i)_i$ is a net in $L\cap K$. As $K$ is compact, there is a subnet $(x_{i_k})_k$ converging to some $x\in K$. As $L$ is closed, we must have $x\in L$. Hence $x\in L\cap K$ and consequently $L\cap K$ is compact.