Created
October 20, 2022 22:54
-
-
Save ebubekirsezer/e9f4c82e711fe39dcedd8bfa809948b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension Collection { | |
func arrayValue<T>() -> [T] where Self.Element == T { | |
guard self.count > 0 else { return [] } | |
var list: [T] = [] | |
list.append(contentsOf: self) | |
return list | |
} | |
subscript (safe index: Index) -> Element? { | |
return indices.contains(index) ? self[index] : nil | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment