[swift-users] the pain of strings
Adrian Zubarev
adrian.zubarev at devandartist.com
Fri Jun 30 17:13:42 CDT 2017
This looks way better than the subscript in Python and 1000 times better than your example. It might be a good idea to look up possible API first before writing such ugly long lines. I mean they get the job done, but just why so complicated? :(
--
Adrian Zubarev
Sent with Airmail
Am 1. Juli 2017 um 00:08:47, Adrian Zubarev (adrian.zubarev at devandartist.com) schrieb:
let longString = "1234567890"
print(longString.suffix(2)) // prints "90"
--
Adrian Zubarev
Sent with Airmail
Am 30. Juni 2017 um 23:45:01, David Baraff via swift-users (swift-users at swift.org) schrieb:
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))
_______________________________________________
swift-users mailing list
swift-users at swift.org
https://lists.swift.org/mailman/listinfo/swift-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170701/8a26833d/attachment.html>
More information about the swift-users
mailing list