Created
April 23, 2019 16:03
-
-
Save rayfix/fc765c34e36df5b91b9d7bea6c18af6e to your computer and use it in GitHub Desktop.
This file contains 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
struct Dice: Codable { | |
var range: Range<Int> | |
init<R: RangeExpression>(range expr: R) where R.Bound == Int { | |
range = expr.relative(to: Range<Int>(Int.min...Int.max-1)) | |
} | |
func roll() -> Int { | |
return Int.random(in: range) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment