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

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -