Thanks to visit codestin.com
Credit goes to github.com

Skip to content

srand not implemented, fails silently #639

@wmnnd

Description

@wmnnd

Random::srand seems to be not implemented, instead it fails silently.
I find this problematic because it creates inconsistent results with other Ruby implementations. I have tried this code sample in both MRI and JRuby and received the same results.

On a side note, the methods of Random can only be accessed as Object::method in Opal and not as Random::method.

srand 123
a = [rand(100), rand(100), rand(100)]

srand 123
b = [rand(100), rand(100), rand(100)]

puts "#{a} == #{b}: #{a==b}"
#Expected: [66, 92, 98] == [66, 92, 98]: true

P.S.:
I know that JavaScript's own pseudorandom number generator doesn't support seeding. Would there be any other way to fix this?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions