Sha256: b8913db0de868a59f5e77a13e3864061028ae2425736cb80b690fd54741b8f8b

Contents?: true

Size: 209 Bytes

Versions: 28

Compression:

Stored size: 209 Bytes

Contents

class Array

  #
  # +choose+: choose a random element in the array
  #
  # returns a random element from the array
  #
  #:nodoc:

  def choose
    idx = (rand()*(self.size-1)).round
    self[idx]
  end

end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
ruby-mext-0.6.0 lib/mext/array/choose.rb
ruby-mext-0.5.0 lib/mext/array/choose.rb
ruby-mext-0.4.1 lib/mext/array/choose.rb
ruby-mext-0.4.0 lib/mext/array/choose.rb
ruby-mext-0.3.2 lib/mext/array/choose.rb
ruby-mext-0.3.1 lib/mext/array/choose.rb
ruby-mext-0.3.0 lib/mext/array/choose.rb
ruby-mext-0.2.1 lib/mext/array/choose.rb