# take

## definition

The take method takes an integer N as parameter and will use it to return a new collection consisting of the first N elements.

```scala
def take(n: Int): Repr
```

## demo

```scala
scala> val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut", "Hello World")
donuts: Seq[String] = List(Plain Donut, Strawberry Donut, Glazed Donut, Hello World)

scala> donuts.take(1)
res4: Seq[String] = List(Plain Donut)

scala> donuts.take(2)
res5: Seq[String] = List(Plain Donut, Strawberry Donut)

scala> donuts.take(3)
res6: Seq[String] = List(Plain Donut, Strawberry Donut, Glazed Donut)
```


---

# 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://www.selinux.tech/scala/function-operation/t/take.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.
