NeoFaker.Boolean (neo_faker v0.11.0)

View Source

Functions for generating boolean values.

This module provides utilities to generate random boolean values with configurable probabilities, allowing for controlled randomness.

Summary

Functions

Generates a random boolean value with a configurable probability of returning true.

Functions

boolean(true_ratio \\ 50, opts \\ [])

(since 0.5.0)
@spec boolean(1..100, Keyword.t()) :: boolean() | non_neg_integer()

Generates a random boolean value with a configurable probability of returning true.

By default, returns true or false with equal probability. The true_ratio parameter sets the percentage chance (0–100) of returning true. If the integer: true option is provided, returns 1 for true and 0 for false.

Examples

iex> NeoFaker.Boolean.boolean()
false

iex> NeoFaker.Boolean.boolean(75)
true

iex> NeoFaker.Boolean.boolean(75, integer: true)
1