Here is the code:
class Person {
}
func lastNameForPerson(person: Person, caseFolding: ((String)->(String))? = nil) -> String {
if let folder = caseFolding {
return folder("Smith")
}
return "Smith"
}
print(lastNameForPerson(Person())) // Prints "Smith"
print(lastNameForPerson(Person()) {$0.uppercaseString}) // Prints "SMITH"
if "SMITH" == lastNameForPerson(Person()) {$0.uppercaseString} {
print("It's bob")
}
Was expecting to get "It's bob". But instead got the error:
See Question&Answers more detail:osConsecutive statements must be separated by a new line