Swift Example Code

Just learning Swift and I noticed that Apple's example code on the Swift homepage does not compile in playground! I mean really, am I missing something?

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


extension String 
     { var banana : String 
          { let shortName = String(dropFirst(characters))
                return "\(self) \(self) Bo B\(shortName) Banana Fana Fo F\(shortName)" 
          } 
     } 
let bananaName = "Jimmy".banana


I changed line 03 to: { let shortName = String(dropFirst(self))


This seems to work. I tried to find feedback and let them know, but there seems to be no place for developers to provide simple feedback.

Accepted Answer

This example requires Swift2. The characters-property of String is new and didn't exist in Swift 1.2. So you have to use Xcode7 beta for it.

Thank-you - this helps A LOT. I really could not figure that out!

I just wanted to know if anyone else is having trouble downloading Xcode 7? I cant seem to download it!

Worked fine for me. What error do you get?

Swift Example Code
 
 
Q