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: doc/manual/attribute.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ end
16
16
17
17
Note that from an API point of view, there is no way to distinguish the read access of an attribute with a normal method neither to distinguish a write access of an attribute with a setter. Therefore, the read access of an attribute is called a getter while the write access is called a setter.
18
18
19
-
~~~
19
+
~~~nitish
20
20
var x = foo.bar # Is bar an attribute or a method?
21
21
foo.bar = y # Is bar an attribute or a setter?
22
22
# In fact, we do not need to know.
@@ -28,12 +28,12 @@ By default, a getter is public and a setter is private. The visibility of getter
28
28
additional `writable` keyword.
29
29
30
30
~~~
31
-
class Foo
32
-
var pub_pri: X
33
-
protected var pro_pri: X
34
-
var pub_pub: X is writable
35
-
private var pri_pro: X is protected writable
36
-
var pub_pri2: X is private writable # the default
31
+
class Foo2
32
+
var pub_pri: Int
33
+
protected var pro_pri: Int
34
+
var pub_pub: Int is writable
35
+
private var pri_pro: Int is protected writable
36
+
var pub_pri2: Int is private writable # the default
37
37
end
38
38
~~~
39
39
@@ -43,17 +43,17 @@ Getters and setters of attributes behave like genuine methods that can be inheri
43
43
a redefinition while `redef writable` declares that the setter is a redefinition.
Copy file name to clipboardExpand all lines: doc/manual/method.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,8 @@
2
2
3
3
`fun` declares methods. Methods must have a name, may have parameters, and may have a return type. Parameters are typed; however, a single type can be used for multiple parameters.
4
4
5
-
~~~
6
-
fun foo(x, y: Int, s: String): Bool ...
5
+
~~~nitish
6
+
fun foo(x, y: Int, s: String): Bool # ...
7
7
~~~
8
8
9
9
`do` declares the body of methods. Alike control structures, a one-liner version is available.
@@ -38,7 +38,7 @@ print a.length # no () for length, no () for print
38
38
39
39
However, this last facility requires that the first argument does not start with a parenthesis or a bracket.
40
40
41
-
~~~
41
+
~~~nitish
42
42
foo (x).bar # will be interpreted as (foo(x)).bar
43
43
foo [x].bar # will be interpreted as (foo[x]).bar
44
44
~~~
@@ -140,7 +140,7 @@ Operators and setters are methods that require a special syntax for their defini
140
140
141
141
<!---->
142
142
143
-
~~~
143
+
~~~nitish
144
144
class Foo
145
145
fun +(a: Bar): Baz do ...
146
146
fun -: Baz do ...
@@ -162,7 +162,7 @@ a[b] = c # The bracket setter '[]='
162
162
163
163
`+=` and `-=` are combinations of the assignment (`=`) and a binary operator. These feature are extended to setters where a single `+=` is in fact three method calls: a function call, the operator call, then a setter call.
0 commit comments