Skip to content

Commit

Permalink
Fix bad syntax on Elixir 1.11 and older
Browse files Browse the repository at this point in the history
  • Loading branch information
g-andrade committed Jun 14, 2024
1 parent 6818ef2 commit b3e4355
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/sqids/alphabet.ex
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ defmodule Sqids.Alphabet do
def char_at!(alphabet, index), do: Map.fetch!(alphabet, index)

@spec split_and_exchange!(t(), index) :: t()
def split_and_exchange!(alphabet, split_index) when split_index in 0..(map_size(alphabet) - 1)//1 do
def split_and_exchange!(alphabet, split_index) when split_index >= 0 and split_index <= map_size(alphabet) - 1 do
alphabet_size = map_size(alphabet)

map(alphabet, fn {index, char} ->
Expand All @@ -82,7 +82,7 @@ defmodule Sqids.Alphabet do
end

@spec get_slice_chars!(t(), pos_integer) :: [byte, ...]
def get_slice_chars!(alphabet, size) when size in 1..map_size(alphabet)//1 do
def get_slice_chars!(alphabet, size) when size >= 1 and size <= map_size(alphabet) do
Enum.reduce((size - 1)..0, _acc = [], fn index, acc -> [char_at!(alphabet, index) | acc] end)
end

Expand Down

0 comments on commit b3e4355

Please sign in to comment.