> For the complete documentation index, see [llms.txt](https://docs.graphlinq.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.graphlinq.io/dev-tooling/blocks/array/keep-last-x-elements-in-array.md).

# Keep Last X Elements In Array

The "Keep Last X Elements In Array" block in GraphLinq IDE is crucial for maintaining only the most recent elements in an array.

### Block Description

Part of the Array category, this block is designed to trim an array to a specified size, keeping only the most recent elements.

### Input Parameters

* Array (List): The array to be trimmed.

  Output This block does not have a direct output but modifies the input array to keep only the last specified number of elements.

  Example Use Case In a real-time weather monitoring graph, the "Keep Last X Elements In Array" block can be used to maintain only the most recent temperature readings, discarding older data.
* Amount To Keep (int): The number of elements to retain in the array.

### Output

This block does not have a direct output but modifies the input array to keep only the last specified number of elements.

### Example Use Case

In a real-time weather monitoring graph, the "Keep Last X Elements In Array" block can be used to maintain only the most recent temperature readings, discarding older data.
