|
|
|
@ -117,6 +117,11 @@ p.printName() |
|
|
|
\end{lstlisting} |
|
|
|
|
|
|
|
The output of this code would be \pigOut{brett}. |
|
|
|
You access methods the same way as your would class properties except you include the parenthesis. |
|
|
|
You may also notice a reference to a variable \pigVar{this} in the method definition. |
|
|
|
This special variable is used within methods to refer to the object that the method belongs to. |
|
|
|
So using \pigVar{this} within the method \pigVar{printName} is similar to using the variable \pigVar{p} to access |
|
|
|
the specific instance that that method belongs to. |
|
|
|
|
|
|
|
\subsection{Special Methods} |
|
|
|
|