Return a 2d array

Can anyone let me know what i can do here to return a 2D array? From this below i get: Consecutive declarations on a line must be separated by ';' Thank you

func findLocationsForEachRange() -> [[Double]] {
//var myCount = myLocations.count
var locationsVisitedLatLong: [[Double]] = []
for myLocation in myLocations {
if (! >= WeeklySpan(increment: myValue)) {
locationsVisitedLatLong.append(contentsOf: [[myLocation.latitude, myLocation.longitude]])
}return locationsVistedLatLong[[Double]]

That specific error is caused by you having the return statement on line 9 outside of the curly bracket.

ps If you post code, it really helps if you format it as code (using the </> button). That makes it easier for folks to read and reference (because it includes line numbers).

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

1 Like

FWIW, that error message is frequently the result of programmer error involving brace, comma, or newline placement. I have been that programmer.

1 Like