Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/randomperson/ext/Array.rb

Instance Method Summary collapse

Instance Method Details

#index_in_range(n) ⇒ Object



3
4
5
6
7
8
# File 'lib/randomperson/ext/Array.rb', line 3

def index_in_range( n )
  self.each_with_index do |x, i|
    return i if x === n
  end
  return nil
end

#randObject



10
11
12
# File 'lib/randomperson/ext/Array.rb', line 10

def rand
  self[Kernel.rand(length)]
end