3 ms·
Code example FTA: to 'start clock'. Print "Press Ctrl+C to stop showing the time.\n". while true, A number called 'this hour' is current time's hour,
by Someone 1mo ago
Code example FTA:
to 'start clock'.
Print "Press Ctrl+C to stop showing the time.\n".
while true,
A number called 'this hour' is current time's hour,
A number called 'this minute' is current time's minute,
A number called 'this second' is current time's second,
print "\r->\t{this hour:02}:{this minute:02}:{this second:02}\t<-" without newline,
Wait 1 second.
'start clock'.
There’s a a race condition there because “current time” is read thrice (it could be 7:59:59 when “this hour” is computed and 8:00:00 when “this minute” is computed)
Also, on “reads like English”: “while true” doesn’t sound like that to me. Neither does
{this hour:02}
- TheJostler 1mo agoThe example has been fixed!
- Someone 1mo agoI don’t think you can fix language flaws by fixing examples. Also, you didn’t fix the example, you replaced it by code that did something completely different.
- TheJostler 1mo ago[dead]