Open Azoy opened 5 years ago
cc: @stephentyrone
You're supposed to use Int.random(in: 0...count, using: &generator)
, not call next
directly. See SE-0202 for more details.
We have considered something like having .next( ) return any FixedWidthInteger, but basically "what Jordan said". Most use cases should be using the methods that take a range.
Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Standard Library | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: 7065369b6f42acb03b6e059f6af05a15Issue Description:
Lack of a better bug title, these extension methods on RandomNumberGenerator:
are somewhat difficult to work with. Here is the implementation of randomElement() on Collection:
Granted the numericCast might be unnecessary and you can achieve the same using Int(random), but removing the UnsignedInteger constraint allows for an implementation like so:
This is just one example of where removing this constraint is helpful.