Skip to content

Instantly share code, notes, and snippets.

@mavuio
Created September 28, 2022 09:39
Show Gist options
  • Save mavuio/543b04c842800aeac4077266149fcefd to your computer and use it in GitHub Desktop.
Save mavuio/543b04c842800aeac4077266149fcefd to your computer and use it in GitHub Desktop.
def get_next_in_list(list, item) when is_list(list) do
Enum.find_index(list, fn e -> e == item end)
|> case do
nil ->
nil
idx ->
Enum.at(list, idx + 1)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment