Skip to content

Commit

Permalink
methods ACCEPTS in class Parcel
Browse files Browse the repository at this point in the history
It is a bit incomplete since the spec doesn't really say what it should
do; this patch just implements the case where the invocant has no items, which
is also known as Nil.
  • Loading branch information
moritz committed Mar 11, 2010
1 parent 04ad775 commit 9ef3c7c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/core/Parcel.pm
Expand Up @@ -2,4 +2,13 @@ augment class Parcel {
method elems() { self.Seq.elems }

method list() { self.iterator }

multi method ACCEPTS($x) {
# smart-matching against Nil
if self.elems == 0 {
$x.notdef || ($x.does(::Positional) && $x == 0)
} else {
die "Don't know how to smart-match against a Parcel that doesn't happen to be empty";
}
}
}

0 comments on commit 9ef3c7c

Please sign in to comment.