From 822b394f47231e02043b42437cb5c2dea9197add Mon Sep 17 00:00:00 2001 From: Utkarsh-Singhal-26 Date: Fri, 9 Jan 2026 15:12:55 +0530 Subject: [PATCH 1/2] [Term Entry] Dart Queue: .elementAt() --- .../queue/terms/elementAt/elementAt.md | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 content/dart/concepts/queue/terms/elementAt/elementAt.md diff --git a/content/dart/concepts/queue/terms/elementAt/elementAt.md b/content/dart/concepts/queue/terms/elementAt/elementAt.md new file mode 100644 index 00000000000..ce1308f2a8f --- /dev/null +++ b/content/dart/concepts/queue/terms/elementAt/elementAt.md @@ -0,0 +1,51 @@ +--- +Title: '.elementAt()' +Description: 'Returns the element at the specified index in a queue.' +Subjects: + - 'Computer Science' + - 'Code Foundations' +Tags: + - 'Dart' + - 'Queues' + - 'Methods' +CatalogContent: + - 'learn-dart' + - 'paths/computer-science' +--- + +In Dart, the **`.elementAt()`** method returns the element at the specified index in a queue. This method is part of the `Queue` class under the `dart:collection` library. + +## Syntax +```pseudo +queue.elementAt(index); +``` + +- `queue`: The name of the queue from which an element is to be retrieved. +- `index`: The zero-based position of the element to be retrieved. + +> **Note:** If the index is out of range, this method throws a `RangeError`. + +## Example + +The following example demonstrates the usage of the `.elementAt()` method: +```dart +import 'dart:collection'; + +void main() { + Queue numbers = Queue(); + + numbers.add(10); + numbers.add(20); + numbers.add(30); + numbers.add(40); + + print("Element at index 0: ${numbers.elementAt(0)}"); + print("Element at index 2: ${numbers.elementAt(2)}"); +} +``` + +The output for the above code is as follows: +```shell +Element at index 0: 10 +Element at index 2: 30 +``` \ No newline at end of file From 402211fd8f992bf8774d74088885453f757c97d9 Mon Sep 17 00:00:00 2001 From: Mamta Wardhani Date: Mon, 12 Jan 2026 17:13:51 +0530 Subject: [PATCH 2/2] Improve .elementAt() method documentation Updated the documentation for the .elementAt() method to clarify the parameters and return value. --- .../concepts/queue/terms/elementAt/elementAt.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/content/dart/concepts/queue/terms/elementAt/elementAt.md b/content/dart/concepts/queue/terms/elementAt/elementAt.md index ce1308f2a8f..6b5c51a8cd8 100644 --- a/content/dart/concepts/queue/terms/elementAt/elementAt.md +++ b/content/dart/concepts/queue/terms/elementAt/elementAt.md @@ -2,8 +2,8 @@ Title: '.elementAt()' Description: 'Returns the element at the specified index in a queue.' Subjects: - - 'Computer Science' - 'Code Foundations' + - 'Computer Science' Tags: - 'Dart' - 'Queues' @@ -13,21 +13,28 @@ CatalogContent: - 'paths/computer-science' --- -In Dart, the **`.elementAt()`** method returns the element at the specified index in a queue. This method is part of the `Queue` class under the `dart:collection` library. +In Dart, the **`.elementAt()`** method returns the element at the specified index in a `Queue`. This method is part of the `Queue` class under the `dart:collection` library. ## Syntax + ```pseudo queue.elementAt(index); ``` -- `queue`: The name of the queue from which an element is to be retrieved. +**Parameters:** + - `index`: The zero-based position of the element to be retrieved. +**Return value:** + +Returns the element at the specified `index`. + > **Note:** If the index is out of range, this method throws a `RangeError`. ## Example The following example demonstrates the usage of the `.elementAt()` method: + ```dart import 'dart:collection'; @@ -45,7 +52,8 @@ void main() { ``` The output for the above code is as follows: + ```shell Element at index 0: 10 Element at index 2: 30 -``` \ No newline at end of file +```