exercism/elixir/city-office/HINTS.md

3.7 KiB

Hints

General

1. Document the purpose of the form tools

  • The module attribute @moduledoc can be used to write documentation for a module.

2. Document filling out fields with blank values

  • The module attribute @doc can be used to write documentation for a function.
  • The module attribute @spec can be used to write a typespec for a function.
  • Place the @doc and @spec attributes right before the first function clause of the function that those attributes describe.
  • Refer to the typespecs documentation for a list of all available types.
  • The correct type for strings is defined in the String module.

3. Document splitting values into lists of uppercase letters

  • The module attribute @doc can be used to write documentation for a function.
  • The module attribute @spec can be used to write a typespec for a function.
  • Place the @doc and @spec attributes right before the first function clause of the function that those attributes describe.
  • Refer to the typespecs documentation for a list of all available types.
  • The correct type for strings is defined in the String module.
  • A list is a parametrized type.

4. Document checking if a value fits a field with a max length

  • The module attribute @doc can be used to write documentation for a function.
  • The module attribute @spec can be used to write a typespec for a function.
  • Place the @doc and @spec attributes right before the first function clause of the function that those attributes describe.
  • Refer to the typespecs documentation for a list of all available types.
  • The correct type for strings is defined in the String module.
  • Literal values can be used in a typespec.
  • The pipe | can be used to represent a union of types.

5. Document different address formats

  • The module attribute @type can be use to define a custom public type.
  • Types can be compound, e.g. when specifying a type that's a map, you can also specify the types of the values under the specific keys.
  • The type operator :: can also be used to prepend a variable name to a type.
  • Custom types can be used to define other custom types.

6. Document formatting the address

  • The module attribute @doc can be used to write documentation for a function.
  • The module attribute @spec can be used to write a typespec for a function.
  • Place the @doc and @spec attributes right before the first function clause of the function that those attributes describe.
  • Refer to the typespecs documentation for a list of all available types.
  • The correct type for strings is defined in the String module.
  • Custom types can be used in a typespec.