times(_ callbackWithIndex: (Int) -> Void)

Invoke the callback function n times with zero-based indexes.

Parameters

  • callback: The block with current index
5.times{ print($0) }
// print 0,1,2,3,4