org.scalactic.TimesOnInt
See theTimesOnInt companion object
trait TimesOnInt
Trait providing an implicit conversion that adds a times method to Ints that will repeat a given side-effecting operation multiple times.
Here's an example in which a friendly greeting is printed three times:
3 times println("Hello again, world!")
Running the above code would yield this output:
Hello again, world! Hello again, world! Hello again, world!
If you need to repeat a block of statements multiple times, just enclose them in parentheses, like this:
2 times {
print("Hello ")
print("again, ")
println("world!")
}
Running the above code would yield:
Hello again, world! Hello again, world!
This trait enables times to be invoked on 0 and any positive integer, but attempting to invoke times on a negative integer will result in an IllegalArgumentException.
Attributes
- Companion
- object
- Source
- TimesOnInt.scala
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
object TimesOnInt.type
Members list
In this article