diff options
author | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2009-04-20 09:46:00 +0200 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2009-04-20 09:47:29 +0200 |
commit | 2da5311b94bb1097f146b5db5493db95124d524a (patch) | |
tree | 554367035a020230add8fe295576ba706446c9c0 /pod/perlsyn.pod | |
parent | c3886e8b3633df50e9636123f8fe89c9e6378436 (diff) | |
download | perl-2da5311b94bb1097f146b5db5493db95124d524a.tar.gz |
Document that ~~ overload will only work on the RHS
Diffstat (limited to 'pod/perlsyn.pod')
-rw-r--r-- | pod/perlsyn.pod | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/pod/perlsyn.pod b/pod/perlsyn.pod index ba4ae2aa58..e52d42cfaf 100644 --- a/pod/perlsyn.pod +++ b/pod/perlsyn.pod @@ -681,7 +681,7 @@ entries apply in those cases. ====== ===== ===================== ============= Any undef undefined !defined $a - (overloading trumps everything below) + Any Object invokes ~~ overloading on $object, or dies Hash CodeRef sub truth for each key[1] !grep { !$b->($_) } keys %$a Array CodeRef sub truth for each elt[1] !grep { !$b->($_) } @$a @@ -730,12 +730,13 @@ C<grep>, the smart match operator will short-circuit whenever it can. You can change the way that an object is matched by overloading the C<~~> operator. This trumps the usual smart match semantics. -See L<overload>. +See L<overload>. Since smart matching dispatch is driven by the +right hand side argument, overloading applies only when the object +is on the right of C<~~>. It should be noted that C<~~> will refuse to work on objects that don't overload it (in order to avoid relying on the object's -underlying structure). The only exception is when testing for -definedness with C<$object ~~ undef>. +underlying structure). =head3 Differences from Perl 6 |