Attempt clarifying the pin operator
This commit is contained in:
@@ -8,12 +8,14 @@ defmodule PatternMatching do
|
|||||||
koan "A pattern can change" do
|
koan "A pattern can change" do
|
||||||
a = 1
|
a = 1
|
||||||
a = 2
|
a = 2
|
||||||
assert (a == 2) == ___
|
assert a == ___
|
||||||
end
|
end
|
||||||
|
|
||||||
koan "A pattern can also be strict" do
|
koan "A pattern can also be strict" do
|
||||||
a = 1
|
a = 1
|
||||||
assert ^a = ___
|
assert_raise ___, fn() ->
|
||||||
|
^a = 2
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
koan "Patterns can be used to pull things apart" do
|
koan "Patterns can be used to pull things apart" do
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ defmodule PatternsTests do
|
|||||||
test "Pattern Matching" do
|
test "Pattern Matching" do
|
||||||
answers = [
|
answers = [
|
||||||
1,
|
1,
|
||||||
true,
|
2,
|
||||||
1,
|
MatchError,
|
||||||
{:multiple, [1, [2,3,4]]},
|
{:multiple, [1, [2,3,4]]},
|
||||||
[1,2,3,4],
|
[1,2,3,4],
|
||||||
3,
|
3,
|
||||||
|
|||||||
Reference in New Issue
Block a user