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.16.2 lib/mext/array/choose.rb
ruby-mext-0.16.1 lib/mext/array/choose.rb
ruby-mext-0.16.0 lib/mext/array/choose.rb
ruby-mext-0.15.3 lib/mext/array/choose.rb
ruby-mext-0.15.2 lib/mext/array/choose.rb
ruby-mext-0.15.1 lib/mext/array/choose.rb
ruby-mext-0.15.0 lib/mext/array/choose.rb
ruby-mext-0.14.0 lib/mext/array/choose.rb
ruby-mext-0.13.1 lib/mext/array/choose.rb
ruby-mext-0.13.0 lib/mext/array/choose.rb
ruby-mext-0.12.1 lib/mext/array/choose.rb
ruby-mext-0.12.0 lib/mext/array/choose.rb
ruby-mext-0.11.1 lib/mext/array/choose.rb
ruby-mext-0.11.0 lib/mext/array/choose.rb
ruby-mext-0.10.1 lib/mext/array/choose.rb
ruby-mext-0.10.0 lib/mext/array/choose.rb
ruby-mext-0.9.1 lib/mext/array/choose.rb
ruby-mext-0.9.0 lib/mext/array/choose.rb
ruby-mext-0.8.0 lib/mext/array/choose.rb
ruby-mext-0.7.0 lib/mext/array/choose.rb