-
Notifications
You must be signed in to change notification settings - Fork 22
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
Float ranges #62
Float ranges #62
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Stratus3D thanks for the PR! 💘
It would be great if you could add this change to the CHANGELOG. 🙏
Can you please remove e69ecd4 from this PR? It is already in #61
Could you please also mention #60 in the commit message:
Fixes https://github.com/rantly-rb/rantly/issues/60
@@ -158,7 +158,13 @@ def float(distribution=nil, params={}) | |||
def range(lo=nil,hi=nil) | |||
lo ||= INTEGER_MIN | |||
hi ||= INTEGER_MAX | |||
rand(hi+1-lo) + lo | |||
|
|||
if lo.is_a?(Integer) && hi.is_a?(Integer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a better solution would be using a range in rand: rand(lo..hi)
😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strangely rand(lo..hi)
doesn't work. I don't know why it was written this way originally, but I've left it as it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Introduced in commit 15a4eb0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Stratus3D what do you exactly mean with it doesn't work? 😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Stratus3D I think you didn't see my comment, what do you exactly mean with it doesn't work? can you please elaborate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Stratus3D can you please rebase? I have introduced Rubocop in #66 and I would like to avoid introducing new offenses in this PR. Sorry for that 😢
PR updated! I fixed all the rubocop warnings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not conviced with not using rand(lo..hi)
, but it can be fixed later on. Let 🚢 it! Thanks for the contribution @Stratus3D 💘
@@ -158,7 +158,13 @@ def float(distribution=nil, params={}) | |||
def range(lo=nil,hi=nil) | |||
lo ||= INTEGER_MIN | |||
hi ||= INTEGER_MAX | |||
rand(hi+1-lo) + lo | |||
|
|||
if lo.is_a?(Integer) && hi.is_a?(Integer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Stratus3D I think you didn't see my comment, what do you exactly mean with it doesn't work? can you please elaborate?
Update the
range
generator function so it checks the input range and generates a random float or random integer based on the types of the input numbers.Fixes #60