Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

Getters [11/12]

Why doesn't this code make a pause on each iteration?

Answer

A semicolon (;) symbol ends a statement list. Therefore, the sleepMs statement is not part of the statement list, thus it is outside the for loop.

The code is badly indented. It looks like the sleepMs statement is a part of the loop, but it isn't.

How would you make the sleepMs statement be a part of the statement list?

Solution

for #i=1..20
	: println i*i  << NOT ended by semicolon
	: sleepMs(200);

Loading...