JPC
JPC

Reputation: 5173

coffeescript while/ loop / for multiple statements in beautiful coffee

I have been using something like :

n = 50
force.tick() for i in [0...n]

but I am trying to find a way to do multiple statments with 50 times as able

n = 50
force.tick() 
doSomthing1
doSomething2
    for i in [0...n]

This obviously does not work, Is there a way to do somethign simliar this above query in coffeescript ?

Upvotes: 1

Views: 221

Answers (2)

Bergi
Bergi

Reputation: 664548

Just regular loop syntax instead of a single-line-comprehension:

n = 50
for i in [0...n]
    force.tick()
    doSomthing1
    doSomething2

Upvotes: 4

mpm
mpm

Reputation: 20155

(force.tick();doSomthing1();doSomthing2()) for i in [0...n]

Upvotes: 0

Related Questions