Skip to content

Instantly share code, notes, and snippets.

@Grinnz
Created August 25, 2016 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Grinnz/68c9ed18b2dbfc04a274df45f5173b25 to your computer and use it in GitHub Desktop.
Save Grinnz/68c9ed18b2dbfc04a274df45f5173b25 to your computer and use it in GitHub Desktop.
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]})) }
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