Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Revert "Document behaviour of infix:<but> with non-role RHS"
This reverts commit 9045145.

(placed in the wrong section)
  • Loading branch information
zoffixznet committed Nov 27, 2016
1 parent 9045145 commit 2b2a9be
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions doc/Language/operators.pod6
Expand Up @@ -1212,21 +1212,13 @@ unsuccessfully, resetting the answer to 42.
=head2 infix C«does»
=begin code :skip-test
sub infix:<does>(Mu $obj, Mu $role) is assoc<non>
sub infix:<does>(Mu $obj, Mu:D $obj) is assoc<non>
sub infix:<does>(Mu $obj, Mu $role) is assoc<non>
=end code
Mixes C<$role> into C<$obj> at run time. Requires C<$obj> to be mutable.
Instead of a role, you can provide an instantiated object. In this case,
the operator will create a role for you automatically. The role will contain
a single method named the same as C<$obj.^name> and that returns C<$obj>:
say 42 but 'forty two'; # 'fourty two'
my $s = 12 but class { method ^name ($) { 'warbles' } }.new;
say $s.warbles; # warbles.new
say $s + 42; # 54
C<$role> doesn't need to a be a role, it can be something that knows how
to act like a role, for example enum values.
=head2 infix C«but»
Expand Down

0 comments on commit 2b2a9be

Please sign in to comment.