Sha256: f384d83bb8a54dda36dd81ba7a199df5cd6a613b75f339ccbb75594b20806fce

Contents?: true

Size: 348 Bytes

Versions: 12

Compression:

Stored size: 348 Bytes

Contents

module Array::AtRandom
  def at_random
    self[Kernel.rand(length)] unless empty?
  end
end

Array.send :include, Array::AtRandom

module Array::AtRandom::Etest
  def test_at_random
    array = [ 1, 2, 3, 4, 5 ]
    5.times do
      assert array.include?(array.at_random)
    end
    assert_equal nil, [].at_random
  end
end if VEX_TEST == "base"

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
vex-0.6.2 lib/vex/base/array/at_random.rb
vex-0.4.4 lib/vex/base/array/at_random.rb
vex-0.4.2 lib/vex/base/array/at_random.rb
vex-0.3.3 lib/vex/base/array/at_random.rb
vex-0.2.9 lib/vex/base/array/at_random.rb
vex-0.2.8 lib/vex/base/array/at_random.rb
vex-0.2.7 lib/vex/base/array/at_random.rb
vex-0.2.6 lib/vex/base/array/at_random.rb
vex-0.2.5 lib/vex/base/array/at_random.rb
vex-0.2.2 lib/vex/base/array/at_random.rb
vex-0.2.1 lib/vex/base/array/at_random.rb
vex-0.2 lib/vex/base/array/at_random.rb