Methods

Random::Object

Public Instance Methods

maybe(chance = 0.5, &block) click to toggle source

Random generator that returns true or false. Can also take a block that has a 50/50 chance to being executed.

  maybe  #=> true
  maybe  #=> false
    # File lib/more/facets/random.rb, line 92
92:     def maybe(chance = 0.5, &block)
93:       if block then
94:         yield if rand < chance
95:       else
96:         rand < chance
97:       end
98:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.