Sha256: bf43885c6c46b3f2c5685266861ce24de4b7d04770aa38327d882448ce077028

Contents?: true

Size: 324 Bytes

Versions: 3

Compression:

Stored size: 324 Bytes

Contents

require 'ludy/version'

class Array
  # it would be defined if RUBY_VERSION < '1.9.0', see rdoc in ruby 1.9
  def choice
    self[rand(size)]
  end if Ludy::ruby_before '1.9.0'
  # the choosen element would be deleted. return the choosen
  def choice!
    i = rand size
    r = self[i]
    self.delete_at i
    r
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
godfat-ludy-0.1.13 lib/ludy/array/choice.rb
ludy-0.1.11 lib/ludy/array/choice.rb
ludy-0.1.13 lib/ludy/array/choice.rb