When passing parameters to a function, they are passed as immutable by default. Just as if you declared them as let .
When you pass the coords parameter to the coords method, it is passed as the inout , which means that these values can change, but since the default parameter is an immutable value, the compiler complains.
You can fix this by explicitly telling the compiler that this parameter can be changed by prefixing it with var .
func drawShape(var coords: [CLLocationCoordinate2D]) { var shape = MGLPolygon(coordinates: &coords, count: UInt(coords.count)) mapView.addAnnotation(shape) }
The var parameter prefix means that you can change this value inside the function.
Edit: Swift 2.2
Use the inout keyword instead.
func drawShape(inout coords: [CLLocationCoordinate2D]) { var shape = MGLPolygon(coordinates: &coords, count: UInt(coords.count)) mapView.addAnnotation(shape) }
source share