TITLE: A map of a compact connected manifold with non-empty boundary to a sphere of the same dimension is null-homotopic
QUESTION [5 upvotes]: In Milnor & Kervaire's Groups of Homotopy Spheres paper, this claim:

A map of a compact connected manifold with non-empty boundary to a sphere of the same dimension is null-homotopic

is made without justification or reference. Can anyone see why is it true?
All I can think of is that compact manifolds with non-empty boundary have top homology $0$, so this map induces $0$ in all homology groups (except the $0$th, of course). However, this doesn't seem to help. It's easy to see that the map restricted to the boundary is null-homotopic (since it can't be surjective there, say by Sard's theorem), but that also doesn't seem to help. Any explanations / references are appreciated.

REPLY [3 votes]: This follows from the fact that such a manifold has no top-dimensional cohomology.
Note that one can construct a $K(\mathbb{Z}, n)$ from $S^n$ by gluing on cells of dimension at least $n + 2$ to kill the higher homotopy groups. So the $(n+1)$-skeleton of this $K(\mathbb{Z}, n)$, denoted $K(\mathbb{Z}, n)^{(n+1)}$, is $S^n$. As Eilenberg-MacLane spaces represent cohomology, for any $n$-dimensional manifold $M$ we have
$$H^n(M; \mathbb{Z}) \cong [M, K(\mathbb{Z}, n)] \cong [M, K(\mathbb{Z}, n)^{(n+1)}] \cong [M, S^n]$$
where we use cellular approximation in the second step. Therefore, if $M$ is an $n$-dimensional manifold which is not closed, every map $M \to S^n$ is nullhomotopic.