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
|
||||
functionality, the compiler converts this to a lambda of the form
|
||||
[ ^self.val ]
|
||||
[ ^self::val ]
|
||||
that will be evaluated when the getter is invoked
|
||||
|
||||
Similarly, the compiler synthesizes a lambda for the setter as well.
|
||||
Here, the expression
|
||||
self.val = value
|
||||
self::val = value
|
||||
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:
|
||||
Note that this is the only time it is legal to access private fields
|
||||
via `self` from a lambda. */
|
||||
$ exampleProperty |
|
||||
get => [ ^self.val ],
|
||||
set => [ :x | self.val = x ].
|
||||
get => [ ^self::val ],
|
||||
set => [ :x | self::val = x ].
|
||||
|
||||
/* 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
|
||||
@@ -497,12 +497,12 @@ end
|
||||
|
||||
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
|
||||
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);
|
||||
setAge:100 inUnit:#months;
|
||||
yourself.
|
||||
yourself::
|
||||
|
||||
/* p1 now contains the Person object */
|
||||
/* again, with do..end */
|
||||
|
||||
Reference in New Issue
Block a user