Decrement index in a loop after Swift C-style loops deprecated -


how express decrementing indexed loop in swift 3.0, syntax below not valid more?

for var index = 10 ; index > 0; index-=1{    print(index) }  // 10 9 8 7 6 5 4 3 2 1 

here easier (and more swifty) approach.

for in (0 ..< 5).reversed() {     print(i) // 4,3,2,1,0 }  let array = ["a", "b", "c", "d", "e"] element in array.reversed() {     print(element) // e,d,c,b,a }  array.reversed().foreach { print($0) } // e,d,c,b,a  print(array(array.reversed())) // e,d,c,b,a 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -