Skip to content

SecureRandom.random_number doesn't accept a range #4607

@DeeJayhX

Description

@DeeJayhX

The problem is here:
https://github.com/jruby/jruby/blob/master/lib/ruby/stdlib/securerandom.rb#L147

At some point, the code to handle ranges was removed.

Environment

jruby 9.1.8.0 (2.3.1) 2017-03-06 90fc7ab Java HotSpot(TM) 64-Bit Server VM 25.121-b13 on 1.8.0_121-b13 +jit [mswin32-x86_64]

Windows 10 Professional x64

Expected Behavior

In standard Ruby I can do puts SecureRandom.random_number(50..55) and get a random result between 50 and 55.

Actual Behavior

If I do this in JRuby, I get an argument error for using a Range in place of a Fixnum.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions