An open API service indexing awesome lists of open source software.

https://github.com/krzyzanowskim/collectionsafeindex

Get the element at the specified index only if it is within bounds, otherwise nil
https://github.com/krzyzanowskim/collectionsafeindex

swift

Last synced: 4 months ago
JSON representation

Get the element at the specified index only if it is within bounds, otherwise nil

Awesome Lists containing this project

README

          

# CollectionSafeIndex

Return the element at the specified index only if it is within bounds, otherwise nil.

```swift
let arr = [0,1,2]
let maybe = arr[safe: 3] // nil
```