# Pair

The Pair class represents a 2-element array.

```ruby
var p = Pair(42, 99)

say p.first      #=> 42
say p.second     #=> 99

p.first = "foo"     # change first element
p.second = "bar"    # change second element

say p       #=> Pair("foo", "bar")
```

Linked lists can be created using nested Pair objects:

```ruby
var ll = Pair(1, Pair(2, Pair(3, 4)))

loop {
    say ll.first
    if (ll.second.kind_of(Pair)) {
        ll = ll.second
    }
    else {
        say "Reached end: #{ll.second}"
        break
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://trizen.gitbook.io/sidef-lang/syntax_and_semantics/literals/pair.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
