Hangman.Dictionary (Hangman Dictionary v0.1.24) View Source

Dictionary for the Hangman Game. Returns a random word.

Based on the course Elixir for Programmers by Dave Thomas.

Link to this section Summary

Functions

Returns a random word from the dictionary.

Returns the number of words in the dictionary.

Link to this section Functions

Specs

random_word() :: String.t()

Returns a random word from the dictionary.

Examples

iex> alias Hangman.Dictionary
iex> for _ <- 0..99, uniq: true do
iex>   Dictionary.random_word() =~ ~r/^[a-z]+$/
iex> end
[true]

iex> alias Hangman.Dictionary.WordsAgent
iex> words = Agent.get(WordsAgent, & &1)
iex> Enum.all?(words, & &1 =~ ~r/^[a-z]+$/)
true

Specs

word_count() :: pos_integer()

Returns the number of words in the dictionary.

Examples

iex> alias Hangman.Dictionary
iex> Dictionary.word_count > 0
true