31 lines
1.4 KiB
Markdown
31 lines
1.4 KiB
Markdown
|
# Hints
|
||
|
|
||
|
## General
|
||
|
|
||
|
- Read about protocols in the [official Getting Started guide][getting-started-protocols] or on [elixirschool.com][elixir-school-protocols].
|
||
|
|
||
|
## 1. Define edibility
|
||
|
|
||
|
- There is a [special macro][kernel-defprotocol] for defining protocols.
|
||
|
- Protocols consist of one or more function headers.
|
||
|
- A function header is like a function definition, but without the `do` block. It defines the function name and its arguments, but not what it does.
|
||
|
|
||
|
## 2. Make loaves of bread edible
|
||
|
|
||
|
- There is a [special macro][kernel-defimpl] for implementing a protocol for a given data type.
|
||
|
- Implementing a protocol means writing a function definition for each function header from the protocol.
|
||
|
|
||
|
## 3. Make mana potions edible
|
||
|
|
||
|
- There is a [special macro][kernel-defimpl] for implementing a protocol for a given data type.
|
||
|
- Implementing a protocol means writing a function definition for each function header from the protocol.
|
||
|
|
||
|
## 4. Make poisons edible
|
||
|
|
||
|
- There is a [special macro][kernel-defimpl] for implementing a protocol for a given data type.
|
||
|
- Implementing a protocol means writing a function definition for each function header from the protocol.
|
||
|
|
||
|
[getting-started-protocols]: https://hexdocs.pm/elixir/protocols.html
|
||
|
[elixir-school-protocols]: https://elixirschool.com/en/lessons/advanced/protocols/
|
||
|
[kernel-defprotocol]: https://hexdocs.pm/elixir/Kernel.html#defprotocol/2
|
||
|
[kernel-defimpl]: https://hexdocs.pm/elixir/Kernel.html#defimpl/3
|