-
-
Save Grinnz/68c9ed18b2dbfc04a274df45f5173b25 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/Mojo/Collection.pm b/lib/Mojo/Collection.pm | |
index bd4be5f..244e473 100644 | |
--- a/lib/Mojo/Collection.pm | |
+++ b/lib/Mojo/Collection.pm | |
@@ -27,10 +27,10 @@ sub each { | |
} | |
sub first { | |
- my ($self, $cb) = (shift, shift); | |
+ my ($self, $cb, @args) = @_; | |
return $self->[0] unless $cb; | |
return List::Util::first { $_ =~ $cb } @$self if ref $cb eq 'Regexp'; | |
- return List::Util::first { $_->$cb(@_) } @$self; | |
+ return List::Util::first { $_->$cb(@args) } @$self; | |
} | |
sub flatten { $_[0]->new(_flatten(@{$_[0]})) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Test::More; | |
use List::Util; | |
sub testfirst { List::Util::first { $_ == scalar @_ } @_ } | |
is testfirst(0,2), 2, 'right result'; | |
done_testing; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment