Hartshorne, corollary question

If are two affine varieties, then and are isomorphic if and only if and are isomorphic as -algebras.

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

Let be any variety and let be an affine variety. Then there is a natural bijective mapping of sets

where the left means morphisms of varieties, and the right means homomorphisms of -algebras.

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