Swift Program to Check All Array Elements Satisfy a Condition

You are currently viewing Swift Program to Check All Array Elements Satisfy a Condition

Swift program to check all array elements satisfy a condition

// Swift program to check all array elements
// satisfy a condition

import Swift

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

var res = arr.allSatisfy {
    $0 < 60
}

print(res)

output

true

...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