Skip to content

Commit 2321fa4

Browse files
committed
fix type error
1 parent c93b2d6 commit 2321fa4

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎src/Sequence/Primitive.php‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,13 @@ public function first(): Maybe
217217
#[\Override]
218218
public function last(): Maybe
219219
{
220-
return $this->get($this->size() - 1);
220+
$index = $this->size() - 1;
221+
222+
if ($index === -1) {
223+
return Maybe::nothing();
224+
}
225+
226+
return $this->get($index);
221227
}
222228

223229
/**

0 commit comments

Comments
 (0)