mirror of
https://github.com/github/semantic.git
synced 2024-12-24 23:42:31 +03:00
Array Prism subscripting is safe.
This commit is contained in:
parent
0eca419468
commit
fda61501e1
@ -92,7 +92,12 @@ extension Array : ArrayType {
|
||||
|
||||
extension Prism where To : ArrayType {
|
||||
subscript (index: Int) -> Prism<From, To.Element> {
|
||||
return self >>> Prism<To, To.Element>(forward: { $0.array[index] }, backward: { To(array: [ $0 ]) })
|
||||
return self >>> Prism<To, To.Element>(
|
||||
forward: {
|
||||
let array = $0.array
|
||||
return array.count > index ? array[index] : nil
|
||||
},
|
||||
backward: { To(array: [ $0 ]) })
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user