Hangman.Dictionary (Hangman Dictionary v0.1.23) 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
Link to this section Functions
Specs
random_word() :: String.t()
Returns a random word from the dictionary.
Examples
iex> alias Hangman.Dictionary
iex> [
...> Dictionary.random_word(),
...> Dictionary.random_word(),
...> Dictionary.random_word(),
...> Dictionary.random_word()
...> ]
...> |> Enum.all?(& &1 =~ ~r/^[a-z]+$/)
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