Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle "Expected member name or constructor call after type name" error introduced after Swift3 upgrade

Tags:

swift3

After going through the upgrade to Swift3, the upgrade helper changed

private var myArray = [(String, NSDate, Float)]() //Swift 2.2

to

fileprivate var myArray = [(String, Foundation.Date, Float)] //Swift 3

The new code gives an error Expected member name or constructor call after type name.

Does anyone understand the reason for the error or what the correct syntax approach should be? The proposed solutions from the compiler are to Add arguments after the type to construct a value of the type or Use .self to reference the type object. These don't fix the problem.

like image 631
Shane O'Seasnain Avatar asked Oct 26 '16 18:10

Shane O'Seasnain


1 Answers

You simply need to initialize the array by adding the () at the end.

fileprivate var myArray = [(String, Date, Float)]()
like image 57
nathangitter Avatar answered Sep 28 '22 15:09

nathangitter