Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed types in specs #6

Merged
merged 1 commit into from
May 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/hex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ defmodule HexGrid.Hex do
%HexGrid.Hex{q: 2, r: -1, s: -1}, %HexGrid.Hex{q: 2, r: 0, s: -2},
%HexGrid.Hex{q: 2, r: 1, s: -3}]
"""
@spec neighbourhood(t, integer) :: [t]
@spec neighbourhood(t, non_neg_integer) :: [t]
def neighbourhood(hex, distance) do
for dq <- -distance..distance,
dr <- Enum.max([-distance, -dq - distance])..Enum.min([distance, -dq + distance]) do
Expand Down
6 changes: 3 additions & 3 deletions lib/map.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ defmodule HexGrid.Map do
iex> HexGrid.Map.new_hex(0)
{:ok, %HexGrid.Map{data: %{{0, 0, 0} => %{}}}}
"""
@spec new_hex(integer) :: result
@spec new_hex(non_neg_integer) :: result
def new_hex(radius) do
data = for q <- (-radius)..radius,
r1 = max(-radius, -q - radius),
Expand All @@ -59,7 +59,7 @@ defmodule HexGrid.Map do
@doc """
Sets the arbitrary value on a map.
"""
@spec set(t, HexGrid.Hex.t, any, any) :: result
@spec set(t, HexGrid.Hex.t, Map.key, Map.value) :: result
def set(map, hex, key, value) do
# we only want to set if tile exists
case Map.get(map.data, key_of(hex)) do
Expand All @@ -71,7 +71,7 @@ defmodule HexGrid.Map do
@doc """
Gets the value from the map.
"""
@spec get(t, HexGrid.Hex.t, any) :: any
@spec get(t, HexGrid.Hex.t, Map.key) :: result
def get(map, hex, key) do
case Map.get(map.data, key_of(hex)) do
nil -> {:error, "Tile does not exist"}
Expand Down