twostraws / Unwrap

Learn Swift interactively on your iPhone.
https://www.hackingwithswift.com
Other
2.29k stars 311 forks source link

Free Coding exercises not consistent #168

Open aagd opened 3 years ago

aagd commented 3 years ago

Some questions allow the creation of an empty array with var array:[String] = [], while some would need var array:[String] = [String]() to be valid.

Carrione commented 3 years ago

This is solved by code - see Unwrap/Extensions/String-Variables.swift (line 102) https://github.com/twostraws/Unwrap/blob/main/Unwrap/Extensions/String-Variables.swift

// If folks use explicit type annotation for a collection backed up by an empty initializer, prefer removing the annotation.

replaced = replaced.replacingOccurrences(of: #":\[([A-Za-z]+)\] *= *\[\]"#, with: " = [$1]()", options: .regularExpression)