You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/New Features/Object-Oriented Programming.md
+16-14Lines changed: 16 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -128,29 +128,31 @@ print(human.name) --> John
128
128
129
129
Note that if you have a local variable (or function parameter) called "parent", the `parent` expression will defer to it.
130
130
131
-
## Private Fields
131
+
## Restricted Fields
132
132
133
-
Pluto allows you to specify if a field is 'public'or 'private'. Private fields can only be accessed by the class that defined them.
133
+
Pluto allows you to specify if a field is 'public', 'protected' or 'private'. Private fields can only be accessed by the class that defined them. Protected fields can additionally also be accessed by descendant classes.
134
134
135
135
```pluto
136
-
class Human
137
-
public name
138
-
private age
136
+
class Vehicle
137
+
function __construct(protected manufacturer)
138
+
end
139
+
end
139
140
140
-
function __construct(name, age)
141
-
self.name = name
142
-
self.age = age
141
+
class Car extends Vehicle
142
+
function __construct(manufacturer, private model, public year)
0 commit comments