I have a code that I need to run exactly n times in Swift. What is the shortest possible syntax for that?
n
I am currently using the for loop but
for
Sticking with a for loop - you could extend Int to conform to SequenceType to be able to write:
Int
SequenceType
for i in 5 { /* Repeated five times */ }
To make Int conform to SequenceType you'll could do the following:
extension Int : SequenceType { public func generate() -> RangeGenerator { return (0..