Skip to content

Commit

Permalink
Add last method for collections
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristian Iosif committed Jun 29, 2023
1 parent ce3d885 commit f49f784
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Concerns/EnumerableMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@ public function first(callable|null $callback = null, $default = null)
return $this->items->first($callback, $default);
}

/**
* @template TLastDefault
*
* @param null| (callable(TValue,TKey): bool) $callback
* @param TLastDefault|(\Closure(): TLastDefault) $default
*
* @return TValue|TLastDefault
*/
public function last(callable|null $callback = null, $default = null)
{
return $this->items->last($callback, $default);
}

/**
* @param callable(TValue, TKey): mixed $callback
*
Expand Down

0 comments on commit f49f784

Please sign in to comment.