Unwrap
Unwrap copied to clipboard
Free Coding exercises not consistent
Some questions allow the creation of an empty array with var array:[String] = []
, while some would need var array:[String] = [String]()
to be valid.
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)