I'm looking for an equivalent of:
for(_ <- 1 to n) some.code()
that would be shortest and most elegant. Isn't there in Scala anything similar to this?
rep(n) some.code()
This is one of the most common constructs after all.
PS
I know it's easy to implement rep, but I'm looking for something predefined.
1 to n foreach { _ => some.code() }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With