Plus if you want to play with Swift 4 without running a toolchain or the new 
Xcode you can do it in your browser:

https://swift.sandbox.bluemix.net/#/repl

Just change that repl to Swift 4.

-- 
Adrian Zubarev
Sent with Airmail

Am 1. Juli 2017 um 03:02:38, Adrian Zubarev (adrian.zuba...@devandartist.com) 
schrieb:

The best docs you can get without Xcode I know about is this one here: 

https://developer.apple.com/documentation/swift/string

In Swift 4 a String will yet again become a collection type.

-- 
Adrian Zubarev
Sent with Airmail

Am 1. Juli 2017 um 02:57:05, David Baraff (davidbar...@gmail.com) schrieb:

I only know a little bit of what I’ve read online in blog posts and such.  I 
don’t have access to the Swift 4 API documentation, since i’m not running the 
xcode beta yet.

Is there someplace I can see the actual new API’s for String, in swift 4?  i 
googled but haven’t found it yet.


On Jun 30, 2017, at 5:44 PM, Adrian Zubarev <adrian.zuba...@devandartist.com> 
wrote:

Well you’ve mentioned Swift 4 in your original post, therefore I provided a 
solution using Swift 4. It’s returning a view called `Substring`.

-- 
Adrian Zubarev
Sent with Airmail

Am 1. Juli 2017 um 00:38:42, David Baraff (davidbar...@gmail.com) schrieb:

I’m sorry, but I don’t see suffix() as a member function in any documentation, 
nor does it complete in Xcode.
Is this perhaps only in Swift 4?

If so, that’s a definite improvement!


Begin forwarded message:

From: Adrian Zubarev <adrian.zuba...@devandartist.com>
Subject: Re: [swift-users] the pain of strings
Date: June 30, 2017 at 3:13:42 PM PDT
To: David Baraff <davidbar...@gmail.com>
Cc: swift-users@swift.org

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.zuba...@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@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@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to