Say I had the below api :
func paths() -> [String?] {
return ["test", nil, "Two"]
}
And I was using this in a method where I needed [String]
, hence I had to unwrap it using the simple map
function. I'm currently doing :
func cleanPaths() -> [String] {
return paths.map({$0 as! String})
}
Here, the force-cast will cause an error. So technically I need to unwrap the Strings in the paths
array. I'm having some trouble doing this and seem to be getting silly errors. Can someone help me out here?