Project

General

Profile

Actions

Feature #12357

closed

Random#initialize with a String

Added by nobu (Nobuyoshi Nakada) over 8 years ago. Updated over 8 years ago.

Status:
Feedback
Assignee:
-
Target version:
-
[ruby-core:75407]

Description

https://github.com/ruby/ruby/compare/trunk...nobu:feature/Random%23initialize-string

Currently Random#initialize only accepts an Integer.
It would be useful to accept a String to feed the seed from external sources, I think.

Updated by nobu (Nobuyoshi Nakada) over 8 years ago

I found that rubyspec fails.

Maybe, an alternative is an optional parameter of Random.new_seed for the precision.

Updated by naruse (Yui NARUSE) over 8 years ago

This proposal is not described about "external sources" in detail, and use cases.

If this proposal want to pass data to init_by_array, the intention is clear.
But string is still ambiguous because of its endian.
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/faq.html

Updated by Eregon (Benoit Daloze) over 8 years ago

Nobuyoshi Nakada wrote:

I found that rubyspec fails.

Maybe, an alternative is an optional parameter of Random.new_seed for the precision.

I think it's fine to change the ruby/spec to adapt for this.
The test just intends to verify that argument checking is performed,
but of course a compatible evolution of the API like this seems fine.

Updated by naruse (Yui NARUSE) over 8 years ago

  • Status changed from Open to Feedback

It sounds not useful on the current situation.
Reopen if a Random Utility module requires this.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0