I'm learning functions in swift's array and have encountered the following problem.
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?
I believe you're using Swift 2.2 and the syntax you're using is for Swift 3. Try: