Skip to content

Commit

Permalink
Make .head and .tail only take WhateverCode
Browse files Browse the repository at this point in the history
Instead of Callable.  Being able to take a Callable is not documented
at the moment, and restricting it to WhateverCode does not break any
tests.  Should allow for more uses of Callable with .head/.tail.
  • Loading branch information
lizmat committed Nov 16, 2017
1 parent 6db51f9 commit 5a29a0c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/Any-iterable-methods.pm
Expand Up @@ -1818,7 +1818,7 @@ Did you mean to add a stub (\{...\}) or did you mean to .classify?"
$pulled
)
}
multi method head(Any:D: Callable:D $w) {
multi method head(Any:D: WhateverCode:D $w) {
Seq.new(
Rakudo::Iterator.AllButLastNValues(self.iterator,-($w(0).Int))
)
Expand All @@ -1841,7 +1841,7 @@ Did you mean to add a stub (\{...\}) or did you mean to .classify?"
multi method tail(Any:D: $n) {
Seq.new(
nqp::if(
nqp::istype($n,Callable)
nqp::istype($n,WhateverCode)
&& nqp::isgt_i((my $skip := -($n(0).Int)),0),
nqp::stmts(
(my $iterator := self.iterator).skip-at-least($skip),
Expand Down

0 comments on commit 5a29a0c

Please sign in to comment.