Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Correct spec of context aspects of the self term.
  • Loading branch information
jnthn committed Jan 12, 2015
1 parent 518438a commit 8284cda
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions S12-objects.pod
Expand Up @@ -257,16 +257,15 @@ you may use that directly in list context to produce its elements

method push3 (@x: $a, $b, $c) { ... any(@x) ... }

Note that the C<self> function is not context sensitive and thus always
returns the current object as a single item even in list context.
Hence if your current object happens to be an array but you did not
declare it with an explicit array variable, you need to explicitly
access the elements of the array somehow:

any(self) # WRONG
any(self[]) # okay
any(@(self)) # okay
any(@self) # WRONG unless you declared @self yourself
Note that the C<self> term refers directly to the object the method was invoked
on, and therefore:

class A is Array {
method m() { .say for self }
}
A.new(1, 2, 3).m;

Will produce 3 lines of output.

=head2 Private methods

Expand Down

0 comments on commit 8284cda

Please sign in to comment.