Skip to content

Commit eb85cba

Browse files
committed
address Nate's feedback
1 parent 8c4220e commit eb85cba

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

CHANGELOG.md

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,17 @@ Swift 4.2
7777
* [SE-0202][]
7878

7979
The standard library now provides a unified set of randomization functionality.
80-
Integer types, floating point types, and Bool all introduce a new random
81-
function.
80+
Integer types, floating point types, and Bool all introduce a new static
81+
method that creates a random value.
8282

8383
```swift
8484
let diceRoll = Int.random(in: 1 ... 6)
8585
let randomUnit = Double.random(in: 0 ..< 1)
8686
let randomBool = Bool.random()
8787
```
8888

89-
There are also a couple of collection additions included as well.
89+
There are also additions to select a random element from a collection or
90+
shuffle its contents.
9091

9192
```swift
9293
let greetings = ["hey", "hello", "hi", "hola"]
@@ -96,27 +97,20 @@ Swift 4.2
9697

9798
Core to the randomization functionality is a new `RandomNumberGenerator`
9899
protocol. The standard library defines its own random number generator
99-
called `SystemRandomNumberGenerator` which is backed by a secure and thread
100-
safe random number generator on each platform. All the randomization functions
101-
have a `using:` parameter that take a `RandomNumberGenerator` that users can
102-
pass in their own random number generator.
100+
called `SystemRandomNumberGenerator` which is backed by a secure and
101+
thread-safe random number generator on each platform. All the randomization
102+
functions have a `using:` parameter that take a `RandomNumberGenerator` that
103+
users can pass in their own random number generator.
103104

104105
```swift
105106
struct MersenneTwister: RandomNumberGenerator {
106107
func next() -> UInt64 {
107-
// Algorithm stuff here
108+
// implementation
108109
}
109110
}
110111

111112
var mt = MersenneTwister()
112113
let diceRoll = Int.random(in: 1 ... 6, using: &mt)
113-
let randomUnit = Double.random(in: 0 ..< 1, using: &mt)
114-
let randomBool = Bool.random(using: &mt)
115-
116-
// Collection additions
117-
let greetings = ["hey", "hello", "hi", "hola"]
118-
let randomGreeting = greetings.randomElement(using: &mt)! // This returns an Optional
119-
let newGreetings = greetings.shuffled(using: &mt) // ["hola", "hi", "hey", "hello"]
120114
```
121115

122116
* [SE-0194][]

0 commit comments

Comments
 (0)