I don't know how to solve the following exercise, which is stated in Vakil's The Rising Sea: Foundations of Algebraic Geometry:
11.1.I. EXERCISE. Show that if $Y$ is an irreducible closed subset of a scheme $X$, and $\eta$ is the generic point of $Y$, then the codimension of $Y$ is the dimension of the local ring $\mathscr{O}_{X,\eta}$.
The result is general, so I want to prove directly by definition but failed. I've also thought about proving by affine case, but I don't know the relation of codimensions if reduced to affine case.
Can anyone give me a solution?