Answers for "circular array swift"

0

circular array swift

extension Array {
	subscript(circular index: Int) -> Element? {
		guard index >= 0 && !isEmpty else { return nil }
		guard index >= count else { return self[index] }
		return self[index % count]
	}
}
Posted by: Guest on February-25-2021

Code answers related to "Swift"

Browse Popular Code Answers by Language