Why can't you access the properties of an object in the method of spark: scala?

clipboard.png

how to understand the content of the green part? Why does it feel so awkward? the feeling in the book is also very vague.

Feb.28,2021
The parameters passed in the

Rational class are accessible in the add method.
if add is defined in this way, there is no problem.
but add passes in a rational object. In add, the parameter that is the Rational class.
while the Rational class does not have n and d attributes, so it cannot be accessed.

Menu