るりまサーチ

最速Rubyリファレンスマニュアル検索!
33件ヒット [1-33件を表示] (0.076秒)

別のキーワード

  1. rss date
  2. rss date=
  3. date iso8601
  4. date rfc3339
  5. date jisx0301

ライブラリ

検索結果

Random#rand -> Float (32.0)

一様な擬似乱数を発生させます。

...な値が存在しない範囲を渡した時などに発生します。

//emlist[例][ruby]{
# Kernel.#rand とほぼ同様の使い勝手
prng = Random.new(1234)
prng.rand # => 0.1915194503788923
srand(1234)
rand # => 0.1915194503788923

# max に実数も指定出来...
.... Time.new(2013,1,1)) # => 2012-02-25 03:11:42 +0900
require 'date'
prng.rand(Date.new(2012, 1, 1) ... Date.new(2013,1,1)) # => #<Date: 2012-01-31 ((2455958j,0s,0n),+0s,2299161j)>
# Kernel.#rand とほぼ同様の使い勝手
prng = Random.new(1234)
prng.rand # => 0.1915194503788923
srand...
...2 +0900
# DateTime ではうまくいかない。というのは DateTime#- は
# Rational を返すため。
# Date#- も Rational を返すが通常は整数を表す Rational オブジェクトを返すためうまくいくように見える

# 上と同じ種で再初期化
prng = Random.new(123...

Random#rand(max) -> Integer | Float (32.0)

一様な擬似乱数を発生させます。

...な値が存在しない範囲を渡した時などに発生します。

//emlist[例][ruby]{
# Kernel.#rand とほぼ同様の使い勝手
prng = Random.new(1234)
prng.rand # => 0.1915194503788923
srand(1234)
rand # => 0.1915194503788923

# max に実数も指定出来...
.... Time.new(2013,1,1)) # => 2012-02-25 03:11:42 +0900
require 'date'
prng.rand(Date.new(2012, 1, 1) ... Date.new(2013,1,1)) # => #<Date: 2012-01-31 ((2455958j,0s,0n),+0s,2299161j)>
# Kernel.#rand とほぼ同様の使い勝手
prng = Random.new(1234)
prng.rand # => 0.1915194503788923
srand...
...2 +0900
# DateTime ではうまくいかない。というのは DateTime#- は
# Rational を返すため。
# Date#- も Rational を返すが通常は整数を表す Rational オブジェクトを返すためうまくいくように見える

# 上と同じ種で再初期化
prng = Random.new(123...

Random#rand(range) -> Integer | Float (32.0)

一様な擬似乱数を発生させます。

...な値が存在しない範囲を渡した時などに発生します。

//emlist[例][ruby]{
# Kernel.#rand とほぼ同様の使い勝手
prng = Random.new(1234)
prng.rand # => 0.1915194503788923
srand(1234)
rand # => 0.1915194503788923

# max に実数も指定出来...
.... Time.new(2013,1,1)) # => 2012-02-25 03:11:42 +0900
require 'date'
prng.rand(Date.new(2012, 1, 1) ... Date.new(2013,1,1)) # => #<Date: 2012-01-31 ((2455958j,0s,0n),+0s,2299161j)>
# Kernel.#rand とほぼ同様の使い勝手
prng = Random.new(1234)
prng.rand # => 0.1915194503788923
srand...
...2 +0900
# DateTime ではうまくいかない。というのは DateTime#- は
# Rational を返すため。
# Date#- も Rational を返すが通常は整数を表す Rational オブジェクトを返すためうまくいくように見える

# 上と同じ種で再初期化
prng = Random.new(123...