Squash compiler warnings.

This commit is contained in:
Felipe Sere
2016-03-08 11:36:24 +00:00
parent f2b4cec409
commit 4ca9ab44ad
3 changed files with 5 additions and 4 deletions

View File

@@ -52,7 +52,7 @@ defmodule Functions do
end
def sum_up(thing) when is_list(thing), do: :entire_list
def sum_up(thing), do: :single_thing
def sum_up(_thing), do: :single_thing
koan "You can 'guard' functions against their arguments" do
assert sum_up([1,2,3]) == :entire_list
assert sum_up(1) == :single_thing

View File

@@ -53,8 +53,9 @@ defmodule Arithmetic do
end
koan "it can not divide by zero" do
div_by = fn(n) -> 1 / n end
try do
1 / 0.0
div_by.(0)
rescue
ArithmeticError -> true
end

View File

@@ -6,7 +6,8 @@ defmodule Structs do
end
koan "structs are defined and named after a module" do
assert %Person{}
person = %Person{}
assert person == %Person{}
end
koan "you can access the fields of a struct" do
@@ -53,7 +54,6 @@ defmodule Structs do
koan "are basically maps" do
silvia = %Person{age: 22, name: "Silvia"}
assert is_map(silvia)
assert Map.fetch!(silvia, :age) == 22
end
end