I've run into a question in my textbook and I'm not sure if I understand fully the answer from the solution manual. Here is the question:
Problem: Suppose that $f: A \rightarrow B$ is any function. Then a function $g: B \rightarrow A$ is called a right inverse for $f$ if $f(g(y)) = y$ for all $y \in B$. Prove that if $f$ has a right inverse, $f$ is surjective.
Proof: Suppose $f$ has a right inverse. If $y \in B, f(g(y)) = y$, so $ y \in$ ran $f$. Thus $f$ is surjective.
I get that in order for $f$ to be considered a surjective function, every point in its codomain $B$ must be defined by a point in its domain $A$. However, I don't understand how this is stated in the proof. Can someone please explain the logic of this proof?