Skip to content

Commit

Permalink
The sub form of split() expects the delimiter as second parameter
Browse files Browse the repository at this point in the history
I'm sorry if that breaks many programs out there, but it's the spec.
  • Loading branch information
moritz committed Apr 14, 2009
1 parent f989187 commit 13c2c7c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 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 = *) {
our List multi method split(Code $delimiter, $limit = *) is export {
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 = *) {
our List multi method split($delimiter, $limit = *) is export {
my Int $prev = 0;
my $l = $limit ~~ Whatever ?? Inf !! $limit;
my $s = ~self;
Expand Down Expand Up @@ -135,10 +135,6 @@ 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 13c2c7c

Please sign in to comment.