Is there a brief syntax for executing a block n times in Scala?
Posted
by Motlin
on Stack Overflow
See other posts from Stack Overflow
or by Motlin
Published on 2010-05-16T03:56:36Z
Indexed on
2010/05/16
4:00 UTC
Read the original article
Hit count: 232
scala
I find myself writing code like this when I want to repeat some execution n times:
for (i <- 1 to n) { doSomething() }
I'm looking for a shorter syntax like this:
n.timesRepeat(doSomething())
Does something like this exist in Scala already?
© Stack Overflow or respective owner