
module Kernel

  # 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
  #
  def maybe(chance = 0.5, &block)
    if block then
      yield if rand < chance
    else
      rand < chance
    end
  end

end



#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
=begin test

  require 'test/unit'

  class TCKernel < Test::Unit::TestCase

    def test_maybe
      assert_nothing_raised { maybe }
    end

  end

=end

