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
ONLY 5 CHARACTERS (not including n or code)
r(){}
If you're just testing things and need a REALLY short line, try this. Emphasis on using this for testing, not in production, because no one will know what is going on without documentation.
define this somewhere globally
func r(_ n : UInt, _ c: @escaping () -> Void) { for _ in 0..
call this when you want to run it
r(5) { /*code*/ }