Difference between revisions of "Code Snippet: Slow Printing"

From Coder Merlin
(Created page with "import Foundation let string = "For the world is hollow, and I have touched the sky!" for character in string { print(character, terminator:"") fflush(stdout) usl...")
 
Line 1: Line 1:
== Print characters to the terminal ''slowly'' ==
<syntaxhighlight lang="swift">
import Foundation
import Foundation


Line 8: Line 10:
}
}
print()
print()
</syntaxhighlight>

Revision as of 10:03, 5 December 2018

Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder

Print characters to the terminal slowly[edit]

import Foundation

let string = "For the world is hollow, and I have touched the sky!"
for character in string {
    print(character, terminator:"")
    fflush(stdout)
    usleep(50000)
}
print()