Code Snippet: Random Boolean
From Coder Merlin
Revision as of 00:00, 4 December 2018 by Chukwuemeka-tinashe (talk | contribs) (Created page with "== Generate a Random Integer == <syntaxhighlight lang="swift"> // Simulate flipping a coin and print the result let isHeads = Bool.random() if isHeads { print("Heads") } e...")
Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder
Generate a Random Integer[edit]
// Simulate flipping a coin and print the result
let isHeads = Bool.random()
if isHeads {
print("Heads")
} else {
print("Tails")
}