In John Preskill's lecture notes, I've encountered a brief discussion about observables. He writes some operator $A$ in a Hilbert space as 

$$A=\sum\_n{a\_nP\_n},$$

where $P$ is the projection operator and $a\_n$ denotes an eigenvalue. My question is, why does he say that $P\_n=|n\rangle \langle n|$ if $a\_n$ is a non-degenerate eigenvalue? From my understanding, $P\_n$ is usually written this way, with only one element, $1$, for the n-th row and n-th column. What would $P\_n$ look like if $a\_n$ was degenerate? Also, does this formula assume a specific basis representation for $P\_n$?