doc: replace . as self-index operator with ::
This commit is contained in:
@@ -94,23 +94,23 @@ class Person
|
|||||||
|
|
||||||
In this case, the getter has been set to a variable. To facilitate this
|
In this case, the getter has been set to a variable. To facilitate this
|
||||||
functionality, the compiler converts this to a lambda of the form
|
functionality, the compiler converts this to a lambda of the form
|
||||||
[ ^self.val ]
|
[ ^self::val ]
|
||||||
that will be evaluated when the getter is invoked
|
that will be evaluated when the getter is invoked
|
||||||
|
|
||||||
Similarly, the compiler synthesizes a lambda for the setter as well.
|
Similarly, the compiler synthesizes a lambda for the setter as well.
|
||||||
Here, the expression
|
Here, the expression
|
||||||
self.val = value
|
self::val = value
|
||||||
is converted to the lambda
|
is converted to the lambda
|
||||||
[ :x | self.val = x ]
|
[ :x | self::val = x ]
|
||||||
*/
|
*/
|
||||||
$ exampleProperty | get => self.val, set => self.val = value.
|
$ exampleProperty | get => self::val, set => self::val = value.
|
||||||
|
|
||||||
/* Without the lambda synthesis, the property would look like this:
|
/* Without the lambda synthesis, the property would look like this:
|
||||||
Note that this is the only time it is legal to access private fields
|
Note that this is the only time it is legal to access private fields
|
||||||
via `self` from a lambda. */
|
via `self` from a lambda. */
|
||||||
$ exampleProperty |
|
$ exampleProperty |
|
||||||
get => [ ^self.val ],
|
get => [ ^self::val ],
|
||||||
set => [ :x | self.val = x ].
|
set => [ :x | self::val = x ].
|
||||||
|
|
||||||
/* The `get` element of a property doesn't have to be a lambda, it can
|
/* The `get` element of a property doesn't have to be a lambda, it can
|
||||||
be any value. When the property is accessed, the value provided will
|
be any value. When the property is accessed, the value provided will
|
||||||
@@ -497,12 +497,12 @@ end
|
|||||||
|
|
||||||
for situations where you want to return the recipient after a chain of
|
for situations where you want to return the recipient after a chain of
|
||||||
cascaded messages, you can use the -yourself message, which is understood by
|
cascaded messages, you can use the -yourself message, which is understood by
|
||||||
all objects by default and always returns the object itself.
|
all objects by default and always returns the object itself::
|
||||||
**/
|
**/
|
||||||
|
|
||||||
p1 = Person new(name:'John Doe' age:34);
|
p1 = Person new(name:'John Doe' age:34);
|
||||||
setAge:100 inUnit:#months;
|
setAge:100 inUnit:#months;
|
||||||
yourself.
|
yourself::
|
||||||
|
|
||||||
/* p1 now contains the Person object */
|
/* p1 now contains the Person object */
|
||||||
/* again, with do..end */
|
/* again, with do..end */
|
||||||
|
|||||||
Reference in New Issue
Block a user