-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add inline documentation to remaining public methods
- Loading branch information
Showing
2 changed files
with
13 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
public extension Int { | ||
func times(execute: () -> Void) { | ||
extension Int { | ||
/// Executes supplied closure n-times. | ||
/// Handy for time measurement tests. | ||
/// - Parameter execute: Closure executed n-times. | ||
public func times(execute: () -> Void) { | ||
for _ in 0..<self { | ||
execute() | ||
} | ||
} | ||
|
||
func times<T>(execute: () -> T) -> [T] { | ||
/// Creates array of items by executing supplied | ||
/// closure n-times. Handy for generating | ||
/// arrays of random values. | ||
/// - Parameter execute: Closure returning some item n-times. | ||
public func times<T>(execute: () -> T) -> [T] { | ||
return (0..<self).map { _ in execute() } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters