NeoFaker.Boolean (neo_faker v0.8.0)

View Source

Provides functions for generating boolean values.

This module includes functions to generate random boolean values with configurable probabilities, allowing for controlled randomness in various use cases.

Summary

Functions

Generates a random boolean value.

Functions

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

(since 0.5.0)
@spec boolean(pos_integer(), Keyword.t()) :: boolean()

Generates a random boolean value.

By default, this function returns true or false with equal probability (50% each). An optional true_ratio argument can be provided to adjust the probability of returning true.

If the integer: true option is set, the function 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