module Gemmy::Patches::ObjectPatch::InstanceMethods::Maybe

Public Instance Methods

maybe(chance = 0.5) { || ... } 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… facets

# File lib/gemmy/patches/object_patch.rb, line 111
def maybe(chance = 0.5, &block)
  if block
    yield if rand < chance
  else
    rand < chance
  end
end