Here is a simplified version of my code:
percentage = 0
downloaded = 0
fileSize = 10000
while percentage <= 1
downloaded += 1
percentage = downloaded/fileSize
sleep(0.1)
print " Does not change: #{downloaded/fileSize}, Does not change: #{percentage}, Does change: #{downloaded}\r"
end
The #{downloaded/fileSize}
and the #{percentage}
does not change in the loop. Whilst the variable, downloaded
, is actually changing in #{downloaded}
. Why is #{downloaded/fileSize}
, and #{percentage}
, not changing in the print statement and how can I change this?
The "\r" makes it print on the same line, but removing it doesn't make the print statement work as expected.