mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-01 10:52:14 +00:00
added proc rand for typedesc (#10259)
This commit is contained in:
committed by
Andreas Rumpf
parent
d983d998b2
commit
2b37bf5d5b
@@ -158,10 +158,14 @@ proc rand*[T](x: HSlice[T, T]): T =
|
||||
result = rand(state, x)
|
||||
|
||||
proc rand*[T](r: var Rand; a: openArray[T]): T {.deprecated.} =
|
||||
## returns a random element from the openarray `a`.
|
||||
## Returns a random element from the openarray `a`.
|
||||
## **Deprecated since v0.20.0:** use ``sample`` instead.
|
||||
result = a[rand(r, a.low..a.high)]
|
||||
|
||||
proc rand*[T: SomeInteger](t: typedesc[T]): T =
|
||||
## Returns a random integer in the range `low(T)..high(T)`.
|
||||
result = cast[T](state.next)
|
||||
|
||||
proc rand*[T](a: openArray[T]): T {.deprecated.} =
|
||||
## returns a random element from the openarray `a`.
|
||||
## **Deprecated since v0.20.0:** use ``sample`` instead.
|
||||
|
||||
Reference in New Issue
Block a user