Skip to content

Files

Latest commit

 

History

History
35 lines (18 loc) · 462 Bytes

legacy_random.md

File metadata and controls

35 lines (18 loc) · 462 Bytes

Pattern: Use legacy random function

Issue: -

Description

Prefer using type.random(in:) over legacy functions.

Examples of correct code:

Int.random(in: 0..<10)


Double.random(in: 8.6...111.34)


Float.random(in: 0 ..< 1)

Examples of incorrect code:

arc4random(10)


arc4random_uniform(83)


drand48(52)

Further Reading