diff options
author | Nobuyoshi Nakada <[email protected]> | 2023-08-29 10:56:56 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2023-08-29 10:56:56 +0900 |
commit | 7e5c662a6f2e8435f8103bc16185bed6759cc557 () | |
tree | c8e6fb7cbc431e59400cf6f9200a335462b4ce88 /lib/random | |
parent | c4fc9477aa5f77a69a40b619b7144f2b118b772e (diff) |
[Feature #18183] Add `chars:` option to `Random#alphanumeric`
-rw-r--r-- | lib/random/formatter.rb | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -226,11 +226,13 @@ module Random::Formatter # # The argument _n_ specifies the length, in characters, of the alphanumeric # string to be generated. # # If _n_ is not specified or is nil, 16 is assumed. # It may be larger in the future. # - # The result may contain A-Z, a-z and 0-9. # # require 'random/formatter' # @@ -238,8 +240,13 @@ module Random::Formatter # # or # prng = Random.new # prng.alphanumeric(10) #=> "i6K93NdqiH" - def alphanumeric(n=nil) n = 16 if n.nil? - choose(ALPHANUMERIC, n) end end |