Przemek Przemek - 1 year ago 95
Scala Question

Most elegant repeat loop in Scala

I'm looking for an equivalent of:

for(_ <- 1 to n)

that would be shortest and most elegant. Isn't there in Scala anything similar to this?


This is one of the most common constructs after all.


I know it's easy to implement rep, but I'm looking for something predefined.

Answer Source
1 to n foreach { _ => some.code() }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download