Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/random_word_generator/array_ext.rb

Instance Method Summary collapse

Instance Method Details

#randomizeObject



3
4
5
6
# File 'lib/random_word_generator/array_ext.rb', line 3

def randomize
  arr = self.dup
  arr.collect { arr.slice!(rand(arr.length)) }
end

#randomize!Object



8
9
10
11
12
# File 'lib/random_word_generator/array_ext.rb', line 8

def randomize!
  arr = self.dup
  result = arr.collect { arr.slice!(rand(arr.length)) }
  self.replace result
end