Swift: How to use for-in loop with an optional?

If set of operations to be applied to all elements of the array, it is possible to replace for-loop with forEach{} closure and use optional chaining:

var arr: [Int]? = [1, 2, 3]
arr?.forEach{print($0)}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)