[swift-evolution] Proposal: for loops with return values

Amir Michail a.michail at me.com
Thu Jan 14 14:30:07 CST 2016


These would be like the unrolled versions of Python’s generator expressions.

Examples:

let a:[Int] = for x in l { yield x*2 }

let b:[(Int,Int)] = for row in 0..<m { for col in 0..<n { yield (row,col) } }

let c:[(Int,Int)] = for row in 0..<m { for col in 0..<n where row+col < 5 { yield (row,col) } }



More information about the swift-evolution mailing list