0

I'm learning functions in swift's array and have encountered the following problem.

enter image description here

I copied the code directly from swift's API so didn't expect to have any problem. Can someone please tell me why is it giving out error message when typed in playground?

4
  • Swift 2 or Swift 3? Commented Jul 21, 2016 at 22:30
  • i believe the API i'm looking at is for swift 3 Commented Jul 21, 2016 at 22:33
  • Are you in Xcode 8? Commented Jul 21, 2016 at 22:34
  • 1
    You need Xcode 8 for Swift 3. Commented Jul 21, 2016 at 23:06

1 Answer 1

1

I believe you're using Swift 2.2 and the syntax you're using is for Swift 3. Try:

print(a.startsWith(b))
Sign up to request clarification or add additional context in comments.

1 Comment

Best way to figure these out is to start typing a.star and see what Xcode autocomplete offers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.