Tutorial by Examples

When you document your code with @doc, you can supply code examples like so: # myproject/lib/my_module.exs defmodule MyModule do @doc """ Given a number, returns `true` if the number is even, otherwise `false`. ## Example iex> MyModule.even?(2) true ie...
Because generating documentation is based on markdown, you have to do 2 things : 1/ Write your doctest and make your doctest examples clear to improve readability (It is better to give a headline, like "examples" or "tests"). When you write your tests, do not forget to give 4 s...
You can do a multiline doctest by using '...>' for the lines following the first iex> Foo.Bar.somethingConditional("baz") ...> |> case do ...> {:ok, _} -> true ...> {:error, _} -> false ...> end true

Page 1 of 1