Skip to content

Commit

Permalink
Adds goBack assert to catch negative counts (#41)
Browse files Browse the repository at this point in the history
Thanks to @Kondamon!
  • Loading branch information
johnpatrickmorgan committed Jul 26, 2022
1 parent 7c01206 commit 5777d76
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Sources/FlowStacks/RoutableCollection+utilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ public extension RoutableCollection where Element: RouteProtocol {
self.count - count >= 0,
"Can't go back\(count == 1 ? "" : " \(count) screens") - the screen count is \(self.count)"
)
guard self.count - count >= 0 else { return }
assert(
count >= 0,
"Can't go back \(count) screens - count must be positive"
)
guard self.count - count >= 0, count >= 0 else { return }
removeLast(count)
}

Expand Down

0 comments on commit 5777d76

Please sign in to comment.