lör 2007-11-10 klockan 09:29 -0800 skrev Juan-Pablo Caceres:
Hi there,
I have another question concerning time logic. The following 2 examples are similar:
// 1) while (true) { <<<"HELLO">>>; 1::second => now; }
// 2) while (1::second => now) { <<<"HELLO">>>; }
So the question is, is the second case using some syntactic sugar? Because conceptually it doesn't sound right to me. Maybe the chuck gurus out there can make more sense of it?
Well, it's pretty easy, actually. While takes an expression, and if that expression returns true, it evaluates the code inside the brackets, and then it tests the expression again. This expression can be anything from "true", to "i<100", or even a function (that can do absolutely anything). in the second case it's "1::second=>now", which will return true when 1 second have passed. Hope that helps, Gasten