mirror of
https://github.com/github/semantic.git
synced 2024-12-25 07:55:12 +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