Skip to content

Conversation

@azakordonets
Copy link

Upper bond cannot be less the lower bond. Added unit tests as well.

@thellimist
Copy link
Owner

thellimist commented Jan 7, 2018

I think this is a Swift 3 change. Could you add the necessary checks and tests as well?

https://github.com/azakordonets/SwiftRandom/blob/026db916dc668c5bd9ca978b1252d322820389f3/SwiftRandom/Randoms.swift#L21-L27

Thanks

@azakordonets
Copy link
Author

Done

#if swift(>=3)
return random(range.lowerBound, range.upperBound)
#else
return random(range.lowerBound, range.upperBound - 1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming this is correct. Based on that, the parameters are reversed and -1 should go to swift 3 >=. I haven't tested it so my assumption might be wrong. I'd appreciate if you can confirm both Int and Int32 works.

Thanks

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

Successfully merging this pull request may close these issues.

2 participants