Last active
June 13, 2017 13:10
-
-
Save bennokress/b80d597db6b5d9d86449853a759d02aa to your computer and use it in GitHub Desktop.
Extensions for Swift's Bool Type
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
extension Bool { | |
static func random(trueProbability: Int = 50) -> Bool { | |
// NEEDS THE INT EXTENSION for a random Int! --> IntExtensions.swift | |
return Int.random(between: 1, and: 100) <= trueProbability ? true : false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment