Skip to content

Commit

Permalink
refactor: array.shift() renamed amount to offset
Browse files Browse the repository at this point in the history
  • Loading branch information
glaphi committed Mar 19, 2023
1 parent 62d2fb6 commit eafdcde
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Sources/Extensions/Array+Shift.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
extension Array {
mutating func shift(_ amount: Int) {
var amount = amount
guard -count...count ~= amount else { return }
if amount < 0 { amount += count }
self = Array(self[amount ..< count] + self[0 ..< amount])
mutating func shift(_ offset: Int) {
var offset = offset
guard abs(offset) < count else { return }
if offset < 0 { offset += count }
self = Array(self[offset ..< count] + self[0 ..< offset])
}
}

0 comments on commit eafdcde

Please sign in to comment.