exercism/elixir/stack-underflow/HINTS.md

1.2 KiB

Hints

General

  • Read about errors in the Getting Started guide.
  • Read about defexception in the documentation.
  • Read about the Exception behaviour in the documentation.
  • Read the code snippets from the introduction.

1. Error for Division by Zero

2. Error when encountering stack underflow

  • Implement the module, specifying the message using a special built-in macro for defining exceptions.
  • You can use one of the Exception Behaviour callbacks to define an exception whose message changes based on the arguments passed to raise/2.
  • Modules can be nested inside of other modules.

3. Write a dividing function

  • Write a multi-clause function using guards for control-flow.
  • You can pattern match in the function argument list to bind the stack's values to variables.