Skip to content

Commit

Permalink
no more smartmatch
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 7, 2013
1 parent eff7e8d commit 0cc36c0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/Mojo/Collection.pm
Expand Up @@ -28,12 +28,15 @@ sub each {

sub first {
my ($self, $cb) = @_;
return $cb ? List::Util::first { $_ ~~ $cb } @$self : $self->[0];
return $self->[0] unless $cb;
return List::Util::first { $cb->($_) } @$self if ref $cb eq 'CODE';
return List::Util::first { $_ =~ $cb } @$self;
}

sub grep {
my ($self, $cb) = @_;
return $self->new(grep { $_ ~~ $cb } @$self);
return $self->new(grep { $cb->($_) } @$self) if ref $cb eq 'CODE';
return $self->new(grep { $_ =~ $cb } @$self);
}

sub join {
Expand Down

0 comments on commit 0cc36c0

Please sign in to comment.