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

Range for floats? #60

Closed
Stratus3D opened this issue Dec 27, 2018 · 2 comments
Closed

Range for floats? #60

Stratus3D opened this issue Dec 27, 2018 · 2 comments
Labels

Comments

@Stratus3D
Copy link
Contributor

I've been using the range method to select integers within a specified range, and I see there is a float method that returns a random float, but I need a random float within a specified range. Something like:

range_float(23.4, 56.7) 
# => 34.56

Is this something that exists in Rantly? And if not would a contribution to add this method be welcome? Or is there a better way of doing this outside of Rantly?

@Stratus3D
Copy link
Contributor Author

I'm using https://stackoverflow.com/a/1711720/1245380 for now.

It looks like I could update the existing range method to handle floats as well as strings, and implicitly generate the right type of range. Adding a new range_float method should also be easy too.

@Ana06
Copy link
Member

Ana06 commented Dec 27, 2018

I would say there is a bug:

Rantly { range(23.4, 56.7) } #=> 54.4
Rantly { range(23.4, 56) } #=> 29.4
Rantly { range(3, 28.9) } #=> 27
Rantly { range(3.0, 28.9) } #=> 25.0

At least it should give an exception if we don't want floats in range. 🤔

@Ana06 Ana06 added the bug 🐛 label Dec 27, 2018
@Stratus3D Stratus3D mentioned this issue Jan 2, 2019
@Ana06 Ana06 closed this as completed in #62 Jan 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants