Map Function in Swift -
i working map function in swift. seeing use of "$0" , not know means. "$0" pointer current element of array?
stringarray = newstringarray.map({"\($0)new"})
i wouldn't use word pointer, think have right idea. when use map
here, you're taking array , applying function every element in array. here, function takes in 1 argument (a string) , outputs string. $0
refers first argument function you're calling which, in case, argument.
the anonymous sort of functions pass map called closures. looking @ apple's official documentation on closures might helpful! here's link: https://developer.apple.com/library/prerelease/ios/documentation/swift/conceptual/swift_programming_language/closures.html
Comments
Post a Comment