I want a Ruby method to return true
based on a percent probability.
def random_true(probability)
# Math to randomly return true based on weighted probability
end
Then I could just call random_true(0.4)
(implying 40% chance of it returning true
).
Would also be fine if it was a simple one-liner that didn't even need a method.
i.e. return true if XYZ