NeoFaker.Boolean (neo_faker v0.15.0)

Copy Markdown View Source

Functions for generating random boolean values.

Provides a single function to generate true or false with a configurable probability.

Summary

Functions

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

Functions

boolean(true_ratio \\ 50)

(since 0.5.0)
@spec boolean(0..100) :: boolean()

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

The true_ratio parameter sets the percentage chance (0–100) of returning true. Defaults to 50.

Examples

iex> NeoFaker.Boolean.boolean()
false

iex> NeoFaker.Boolean.boolean(75)
true

iex> NeoFaker.Boolean.boolean(0)
false

iex> NeoFaker.Boolean.boolean(100)
true