Navigation Menu

Skip to content

Commit

Permalink
Revert "The sub form of split() expects the delimiter as second param…
Browse files Browse the repository at this point in the history
…eter"

The spec was also reverted, we just follow its lead...
  • Loading branch information
moritz committed Apr 17, 2009
1 parent ecca702 commit 01d7ded
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/setting/Any-str.pm
Expand Up @@ -50,7 +50,7 @@ class Any is also {
$char
}

our List multi method split(Code $delimiter, $limit = *) is export {
our List multi method split(Code $delimiter, $limit = *) {
my $s = ~self;
my $l = $limit ~~ Whatever ?? Inf !! $limit;
my $keep = '';
Expand All @@ -75,7 +75,7 @@ class Any is also {
}

# TODO: substitute with '$delimiter as Str' once coercion is implemented
our List multi method split($delimiter, $limit = *) is export {
our List multi method split($delimiter, $limit = *) {
my Int $prev = 0;
my $l = $limit ~~ Whatever ?? Inf !! $limit;
my $s = ~self;
Expand Down Expand Up @@ -135,6 +135,10 @@ class Any is also {
}
}
multi sub split($delimiter, $target, $limit = *) {
$target.split($delimiter, $limit);
}
# TODO: '$filename as Str' once support for that is in place
multi sub lines(Str $filename,
:$bin = False,
Expand Down
2 changes: 1 addition & 1 deletion t/01-sanity/07-split.t
Expand Up @@ -4,7 +4,7 @@ use v6;
say "1..4";

my $string = "foo!bar!baz";
my @array = split $string, '!';
my @array = split "!", $string;

if @array[0] eq "foo" { say "ok 1" } else { say "not ok 1" }
if @array[1] eq "bar" { say "ok 2" } else { say "not ok 2" }
Expand Down

0 comments on commit 01d7ded

Please sign in to comment.