Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluate API for random(inRange:) #89

Open
andrewdolce opened this issue Nov 17, 2016 · 1 comment
Open

Evaluate API for random(inRange:) #89

andrewdolce opened this issue Nov 17, 2016 · 1 comment
Assignees

Comments

@andrewdolce
Copy link

andrewdolce commented Nov 17, 2016

From a TODO in UnsignedInteger+Extensions: There is a public function random that takes in a CountableClosedRange of integers and returns a random int from within the range. The TODO comment suggests that this function could live as a member function on CountableClosedRange. So it would look something like:

(0..<10).ip_random()

I think to address this issue we need to:

  1. Start a discussion about whether we like this idea.
  2. Try switching the code to use the new API, with updated test coverage.

Not necessarily in that order. I think taking a stab at (2) could help inform (1).

@brightredchilli
Copy link
Contributor

I say we go ahead and do it.

This interface ip_random(0..<10) seems very C-style and not swift-3 like.

Take:

dispatch_async(dispatch_get_main_queue(), ...)

vs

DispatchQueue.main.async( ... )

or any one of the map/reduce operators that have now gone on to be implemented in the collection extensions as opposed to being implemented as global functions. Happy to stand corrected on this though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants