December 2017
Beginner to intermediate
470 pages
12h 29m
English
Since we placed the a, b, and own_color in the private list in the class definition, they remain private, and this is how encapsulation is enforced in R6. As you can see, we were not allowed to assign directly to the a attribute as we expected, since it was placed in the private list. This makes sure that we can't have attributes or methods marked as private directly from outside the object, and prevents us from making bad decisions when coding. This is a great advantage of the R6 model.
Mutability is achieved by using setters (methods used to change a class's attribute). Notice that in this case, we don't need to reassign the resulting object as we do with ...