All modules have an intro.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
defmodule Strings do
|
||||
use Koans
|
||||
|
||||
@intro "Strings"
|
||||
|
||||
koan "Strings are there to represent text" do
|
||||
assert "hello" == ___
|
||||
end
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
defmodule Atoms do
|
||||
use Koans
|
||||
|
||||
@intro "Atoms"
|
||||
|
||||
koan "Atoms are sort of like strings" do
|
||||
adam = :human
|
||||
assert adam == ___
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
defmodule Tuples do
|
||||
use Koans
|
||||
|
||||
@intro "Tuples"
|
||||
|
||||
koan "Tuples can contain different things" do
|
||||
assert {:a, 1, "hi"} == ___
|
||||
end
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
defmodule Lists do
|
||||
use Koans
|
||||
|
||||
@intro "Lists"
|
||||
|
||||
koan "We can see what is ahead" do
|
||||
assert List.first([1, 2, 3]) == ___
|
||||
end
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
defmodule KeywordLists do
|
||||
use Koans
|
||||
|
||||
@intro "KeywordLists"
|
||||
|
||||
koan "Like maps, keyword lists are key-value pairs" do
|
||||
kw_list = [foo: "bar"]
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
defmodule Maps do
|
||||
use Koans
|
||||
|
||||
@intro "Maps"
|
||||
|
||||
@person %{
|
||||
first_name: "Jon",
|
||||
last_name: "Snow",
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
defmodule Structs do
|
||||
use Koans
|
||||
|
||||
@intro "Structs"
|
||||
|
||||
defmodule Person do
|
||||
defstruct [:name, :age]
|
||||
end
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
defmodule PatternMatching do
|
||||
use Koans
|
||||
|
||||
@intro "PatternMatching"
|
||||
|
||||
koan "One matches one" do
|
||||
assert match?(1, ___)
|
||||
end
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
defmodule Functions do
|
||||
use Koans
|
||||
|
||||
@intro "Functions"
|
||||
|
||||
def greet(name) do
|
||||
"Hello, #{name}!"
|
||||
end
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
defmodule Enums do
|
||||
use Koans
|
||||
|
||||
@intro "Enums"
|
||||
|
||||
koan "Knowing how many elements are in a list is important for book-keeping" do
|
||||
assert Enum.count([1, 2, 3]) == ___
|
||||
end
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
defmodule Processes do
|
||||
use Koans
|
||||
|
||||
@intro "Processes"
|
||||
|
||||
koan "You are a process" do
|
||||
assert Process.alive?(self) == ___
|
||||
end
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
defmodule Tasks do
|
||||
use Koans
|
||||
|
||||
@intro "Tasks"
|
||||
|
||||
koan "Tasks can be used for asynchronous computations with results" do
|
||||
task = Task.async(fn -> 3 * 3 end)
|
||||
do_other_stuff()
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
defmodule Agents do
|
||||
use Koans
|
||||
|
||||
@intro "Agents"
|
||||
|
||||
koan "Agents maintain state, so you can ask them about it" do
|
||||
{:ok, pid} = Agent.start_link(fn -> "Hi there" end)
|
||||
assert Agent.get(pid, &(&1)) == ___
|
||||
|
||||
Reference in New Issue
Block a user