Skip to content

Commit

Permalink
Merge pull request #6 from develop7/fix-type-specs
Browse files Browse the repository at this point in the history
Fixed types in specs
  • Loading branch information
rayalex committed May 7, 2017
2 parents 7e07af7 + 36c7604 commit 461a3a2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
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

0 comments on commit 461a3a2

Please sign in to comment.