All modules have an intro.

This commit is contained in:
Felipe Sere
2016-05-11 21:44:18 +01:00
parent 94ab9826ae
commit f5477f0fb0
16 changed files with 30 additions and 12 deletions

View File

@@ -1,6 +1,8 @@
defmodule Strings do
use Koans
@intro "Strings"
koan "Strings are there to represent text" do
assert "hello" == ___
end

View File

@@ -1,6 +1,8 @@
defmodule Atoms do
use Koans
@intro "Atoms"
koan "Atoms are sort of like strings" do
adam = :human
assert adam == ___

View File

@@ -1,6 +1,8 @@
defmodule Tuples do
use Koans
@intro "Tuples"
koan "Tuples can contain different things" do
assert {:a, 1, "hi"} == ___
end

View File

@@ -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

View File

@@ -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"]

View File

@@ -1,6 +1,8 @@
defmodule Maps do
use Koans
@intro "Maps"
@person %{
first_name: "Jon",
last_name: "Snow",

View File

@@ -1,6 +1,8 @@
defmodule Structs do
use Koans
@intro "Structs"
defmodule Person do
defstruct [:name, :age]
end

View File

@@ -1,6 +1,8 @@
defmodule PatternMatching do
use Koans
@intro "PatternMatching"
koan "One matches one" do
assert match?(1, ___)
end

View File

@@ -1,6 +1,8 @@
defmodule Functions do
use Koans
@intro "Functions"
def greet(name) do
"Hello, #{name}!"
end

View File

@@ -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

View File

@@ -1,6 +1,8 @@
defmodule Processes do
use Koans
@intro "Processes"
koan "You are a process" do
assert Process.alive?(self) == ___
end

View File

@@ -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()

View File

@@ -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)) == ___