LINDEX

Since 1.1.0Lists

Syntax

LINDEX key index
  • Flags: readonly
  • ACL categories: @list, @read, @slow
  • Arity: 3

Returns the element at index in the list at key. Negative indexes count from the end.

Reply

  • The element.
  • nil if the index is outside the list, or the key does not exist.

Examples

> RPUSH l a b c
(integer) 3
> LINDEX l 0
"a"
> LINDEX l -1
"c"
> LINDEX l 9
(nil)