diff --git a/prototype/Doubt/JSON.swift b/prototype/Doubt/JSON.swift index 8d34e6fe2..ec35a8fb9 100644 --- a/prototype/Doubt/JSON.swift +++ b/prototype/Doubt/JSON.swift @@ -92,7 +92,12 @@ extension Array : ArrayType { extension Prism where To : ArrayType { subscript (index: Int) -> Prism { - return self >>> Prism(forward: { $0.array[index] }, backward: { To(array: [ $0 ]) }) + return self >>> Prism( + forward: { + let array = $0.array + return array.count > index ? array[index] : nil + }, + backward: { To(array: [ $0 ]) }) } }