I have a code that I need to run exactly n times in Swift. What is the shortest possible syntax for that?
I am currently using the for loop but it is a lot of typing.
for i in 0..<n { /* do something */ } Is there a shorter/nicer way for running same code n times in Swift?
whilefor i in 0 ..< nis already the absolute minimum. You could use a while loop, incrementing a counter but that wouldn't be shorter._is for.for _ in 0..<n { }