Expression pattern of type ‘Double’ cannot match values of type ‘[Double]’?

switch gpa

here gpa is an array of doubles, [Double]

case gpa[1]:

here the case is using a single Double value.

What the error message is telling you is that you can not ask a switch to compare a Double value ( gpa[1] ) to the entire array of gpa’s ( gpa ) because they are different types.

Leave a Comment