Skip to content

Commit

Permalink
added negative check to safe index
Browse files Browse the repository at this point in the history
  • Loading branch information
William Vabrinskas committed Jun 26, 2023
1 parent 6a2cc07 commit 9f0b923
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Sources/NumSwift/BaseNumeric.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public extension Array {
}

subscript(safe safeIndex: Int) -> Element? {
if safeIndex < self.count {
if safeIndex >= 0,
safeIndex < self.count {
return self[safeIndex]
}

Expand Down

0 comments on commit 9f0b923

Please sign in to comment.