Sequence of elements, but "connection is not available: throw joinWithSeparator () error"

Why do I get the "join is unavailable: call joinWithSeparator()" error message on line 16 (last line below) when I try to run it on the playground? And how can I fix this?

class Person {
    var firstName: String?
    var lastName: String?
    let gender = "female"

    func fullName() -> String {
        var parts: [String] = []

        if let firstName = self.firstName {
            parts += [firstName]
        }

        if let lastName = self.lastName {
            parts += [lastName]
        }
        return " ".join(parts)
    }
} 
+4
source share
2 answers

The error message tells you what the problem is, and it tells you how to fix it. Read the error message! Make a bug report!

return parts.joinWithSeparator(" ")
+4
source

The correct answer to the question “why” is part of the question:

String join Swift 2. , , "", Swift 2 .

.

0

Source: https://habr.com/ru/post/1623497/


All Articles