In Algebraic Geometry, chapter 3, Robin Hartshorne proves that for an affine variety (irreducible variety) $Y$, it follows that the ring of regular functions $\mathcal{O}(Y)$ is isomorphic to the coordinate ring of that variety $A(Y)$.
This he proves by first proving that both $\mathcal{O}(Y)$ and $\mathcal{O}_p$ are subrings of the function field $K(Y)$ whose elements are the rational functions on $Y$, and then proving that $A(Y)_{\mathfrak{m}_p} \cong \mathcal{O}_p$. Then embedding both $A(Y)_{\mathfrak{m}_p}$ and $A(Y)$ in $K(Y)$ he gets the chain \begin{equation*} A(Y) \subseteq \mathcal{O}(Y) \subseteq \bigcap_{p \in Y} \mathcal{O}_p = \bigcap_{\mathfrak{m}_p} A(Y)_{\mathfrak{m}_p} = A(Y) , \end{equation*} and concludes that $A(Y) \cong \mathcal{O}(Y)$.
My question is, does $A(Y) \cong \mathcal{O}(Y)$ hold true if $Y$ is an arbitrary affine algebraic set that is not necessarily a variety, (does it hold true if $Y$ is a reducible variety)?
The problem, such as I'm seeing it, is that $K(Y)$ is not necessarily well-defined as a ring if $Y$ is not a variety (irreducible variety), and then you cannot embed $A(Y)$ or $A(Y)_{\mathfrak{m}_p}$ in it through a ring morphism.