[swift-users] the pain of strings

David Baraff davidbaraff at gmail.com
Fri Jun 30 16:44:45 CDT 2017


I know, I’ve read tons about about this.  I sympathize.  Unicode, it’s all very complex.

But.

  BUT.

Python:
  shortID = longerDeviceID[-2:]		# give me the last two characters

Swift:
  let shortID = String(longerDeviceID.characters.dropFirst(longerDeviceID.characters.count - 2))

I can’t even read the above without my eyes glazing over.  As has been pointed out, an API which demands this much verbosity is crippling for many developers, to say the least.

With Swift 4, am I correct that it will be at least:

  let shortID = String(longerDeviceID.dropFirst(longerDeviceID.count - 2))





More information about the swift-users mailing list