The randomNumber() function currently takes two Number arguments, converts them to integers and returns a random number in the open interval.
Proposed solution
I think the following changes would improve the function:
- shorten the name to just
random()
- create a 0-arg version which returns a Double in the interval 0.0 - 1.0
- provide two alternatives for the 2-arg version which return either an Long or a Double, depending on type of the parameters which are passed in
Alternatives considered
- the 2-arg integer version could have a different name like
randint a la Python
- a variant that accepts a seed value could be useful for those who want reproducible results
The
randomNumber()function currently takes two Number arguments, converts them to integers and returns a random number in the open interval.Proposed solution
I think the following changes would improve the function:
random()Alternatives considered
randinta la Python