[swift-users] Misleading? cannot subscript a value of type 'inout [PathPoint]' with optional field

Rick Mann rmann at latencyzero.com
Fri Nov 11 15:29:21 CST 2016


I think the error I'm getting here is misleading. Should I file a bug?

import CoreGraphics

func
+=(inLHS : inout CGPoint, inRHS : CGPoint)
{
    inLHS.x += inRHS.x
    inLHS.y += inRHS.y
}

struct
PathPoint
{
    var    anchorPt:    CGPoint?
}

var points = [PathPoint()]

let dv = CGPoint(x: 0, y: 0)
points[0].anchorPt = dv
points[0].anchorPt += dv


Playground execution failed: error: MyPlayground.playground:17:7: error: cannot subscript a value of type 'inout [PathPoint]' (aka 'inout Array<PathPoint>')
points[0].anchorPt += dv
~~~~~~^



-- 
Rick Mann
rmann at latencyzero.com




More information about the swift-users mailing list