Add pipe and pin operators koans

This commit is contained in:
Makis Otman
2016-03-09 09:51:19 +00:00
parent e0c793638f
commit 741e870222
2 changed files with 19 additions and 0 deletions

View File

@@ -92,4 +92,13 @@ defmodule Functions do
koan "You can 'capture' functions if you want to pass them around as values" do
assert multiply_then_call(2, &square/1) == 100
end
koan "functions can be combined elegantly with the pipe operator" do
result = "full-name"
|> String.split("-")
|> Enum.map(&(String.capitalize(&1)))
|> Enum.join(" ")
assert result == "Full Name"
end
end

View File

@@ -5,6 +5,16 @@ defmodule PatternMatching do
assert match?(1, 1)
end
koan "a pattern can change" do
a = 1
assert a = 2
end
koan "a pattern can also be strict" do
a = 1
assert ^a = 2
end
koan "patterns can be used to pull things apart" do
[head | tail] = [1,2,3,4]