Jones Jones - 1 year ago 108
Swift Question

Generic parameter "Element" could not be inferred -- Swift

So I'm in an Xcode playground, trying to remove the last character from a string. I think it should be really simple, but my code isn't working.

let test = "Get rid of that L"

I get an error on the second line "Generic parameter "Element" could not be inferred"

Answer Source

Don't need the join bit, just do this:

let lastCharRemoved = String(test.characters.dropLast())
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download