Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/active_rubic/base.rb
Instance Method Summary collapse
-
#randomize ⇒ Object
enables randomizing.
- #randomize! ⇒ Object
Instance Method Details
#randomize ⇒ Object
enables randomizing
334 335 336 337 |
# File 'lib/active_rubic/base.rb', line 334 def randomize arr = self.dup self.collect { arr.slice!( rand( arr.length ) ) } end |
#randomize! ⇒ Object
339 340 341 342 343 344 345 |
# File 'lib/active_rubic/base.rb', line 339 def randomize! arr = self.dup # bug here, the array size was halved #result = arr.collect { arr.slice!( rand( arr.length ) ) } result = self.collect { arr.slice!( rand( arr.length ) ) } self.replace result end |