I will go through some methods that I understand and add/update more examples on those methods.
Ex:
Improve on Array() method's example:
Array(1..3) #=> [1, 2, 3]
Array([1, 2]) #=> [1, 2]
Array(1) #=> [1]
Array(nil) #=> []
Improve on srand() method:
# Seeds the pseudorandom number generator to the value of
# <i>number</i>. If <i>number</i> is omitted,
# seeds the generator using a combination of the time, the
# process id, and a sequence number. (This is also the behavior if
# <code>Kernel::rand</code> is called without previously calling
# <code>srand</code>, but without the sequence.) By setting the seed
# to a known value, scripts can be made deterministic during testing, and
# even in different applications sequence of generated randoms numbers
# are the same. The previous seed value is returned.
# Also see <code>Kernel::rand</code>.
#
# srand(2011)
# rand(100) #=> 43
# rand(100) #=> 77
# rand(100) #=> 40
#
# srand(2011)
# rand(100) #=> 43
# rand(100) #=> 77
# rand(100) #=> 40
I will go through some methods that I understand and add/update more examples on those methods.
Ex:
Improve on Array() method's example:
Improve on srand() method: