Hartshorne, corollary question

If $\displaystyle X, Y$ are two affine varieties, then $\displaystyle X$ and $\displaystyle Y$ are isomorphic if and only if $\displaystyle A(X)$ and $\displaystyle A(Y)$ are isomorphic as $\displaystyle k$-algebras.

In my textbook (Hartshorne), it says that this immediately follows from a proposition that states:

Let $\displaystyle X$ be any variety and let $\displaystyle Y$ be an affine variety. Then there is a natural bijective mapping of sets

$\displaystyle \alpha : \text{Hom}(X, Y) \overset{\sim}{\rightarrow} \text{Hom}(A(Y), \mathcal{O}(X))$

where the left $\displaystyle \text{Hom}$ means morphisms of varieties, and the right $\displaystyle \text{Hom}$ means homomorphisms of $\displaystyle k$-algebras.

How is the proof of this immediate from the proposition? I do not see why. Thanks.