Swift Program to Demonstrate the Use of the Enumerated() Function

You are currently viewing Swift Program to Demonstrate the Use of the Enumerated() Function

Swift program to demonstrate the use of the enumerated() function

// Swift program to demonstrate the
// use of enumerated() function

import Swift

var arr:[Int] = [12,10,25,20,50]

for (index, item) in arr.enumerated() {
    print("Item \(item) at position \(index)")
}

Output

Item 12 at position 0
Item 10 at position 1
Item 25 at position 2
Item 20 at position 3
Item 50 at position 4

...Program finished with exit code 0
Press ENTER to exit console.

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply