From f90fc046e55c4179ba38a05eb81d1ee1d4179f8f Mon Sep 17 00:00:00 2001 From: preciz Date: Sun, 8 Nov 2026 13:07:23 +0100 Subject: [PATCH] Clarify the return value and indexing of List.pop_at/3 Assisted-by: Codex CLI:GPT 6.1 Sol --- lib/elixir/lib/list.ex | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/elixir/lib/list.ex b/lib/elixir/lib/list.ex index cdd228cdec2..1ad46c09a0e 100644 --- a/lib/elixir/lib/list.ex +++ b/lib/elixir/lib/list.ex @@ -936,10 +936,15 @@ defmodule List do end @doc """ - Returns and removes the value at the specified `index` in the `list`. + Removes the element at `index` from `list`. + Returns `{value, updated_list}`, where `value` is the + removed element and `updated_list` is the remaining list. - Negative indices indicate an offset from the end of the `list`. - If `index` is out of bounds, the original `list` is returned. + Indices start at `0`. Negative indices count from the + end of the list. Index `-1` selects the last element. + + If `index` is out of bounds, returns `{default, list}`, + where `default` is `nil` unless specified. ## Examples