Writing a loop like this gives some weird output:
============================randomPos = -> print Utils.randomNumber(0, 1) Utils.interval(2,randomPos)
Every two seconds it will multiply the numbers of times the random number is printed.
I only want one random number every 2 seconds…Any ideas? Jorn van Dijk Koen Bok Benjamin Den Boer
check indentation of `Util.interval`
It's recursive. Remove the interval from the function. And just flat out call Utils.interval(....) outside the function.
Then remove randomPos() unless you want it to call immediately.
Indentation is done right.
Another option is to leave it as is and use Utils.delay instead of Utils.interval
Basically the problem you had is you were creating a new interval every two seconds that would create another new interval every two seconds which would create two new intervals every two seconds... Just growing and growing every 2 seconds exponentially.
Jordan Robert Dobson thank you for your explantion! That makes a lot of sense to me now.
No problem. Feel free to tag me if you need help with anything else, I'll try to do what I can.