Skip to content

Instantly share code, notes, and snippets.

@RSchulz
Created October 13, 2010 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RSchulz/624465 to your computer and use it in GitHub Desktop.
Save RSchulz/624465 to your computer and use it in GitHub Desktop.
implicit def intTimes(count: Int) =
new {
/** Iterate ``f`` ``count`` times, not passing the iteration index */
def times(f: => Unit) =
1 to count foreach { _ => f }
/** Iterate ``f`` ``count`` times, passing the iteration index each time */
def iTimes(f: Int => Unit) =
1 to count foreach { i => f(i) }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment