Created
May 5, 2021 08:32
-
-
Save diewland/f58313e566b36609de02536d83c1314d to your computer and use it in GitHub Desktop.
Sleep in 8-bit style
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun sleep8bit (second: Int, width: Int=10, callback: (String)->Unit) { | |
val d = (second * 1000 / width ).toLong() | |
(1..width).forEach { | |
Thread.sleep(d) | |
val progress = "[${"#".repeat(it)}${" ".repeat(width-it)}]" | |
callback(progress) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment