---
title: "Discussion on \"How can we insert an item into an array efficiently?\" | Hashnode"
description: "Discussion on \"How can we insert an item into an array efficiently?\". Sometimes we have to insert items to the first indices of the array\nThe easiest solution can be:\n  var array = [1,2,3,4,5,6,7,8,9]\n  array.insert(0, at: 0)\n  print(array)\nthis solution is going to work, but is it efficient?\nLooking into the Apple Doc..."
url: "https://hashnode.com/posts/how-can-we-insert-an-item-into-an-array-efficiently/632226915483096daa0ac3ba"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [How can we insert an item into an array efficiently?](https://ahmedelgendy.com/how-can-we-insert-an-item-into-an-array-efficiently?utm_source=hashnode&utm_medium=feed)

Sometimes we have to insert items to the first indices of the array The easiest solution can be: var array = \[1,2,3,4,5,6,7,8,9\] array.insert(0, at: 0) print(array) this solution is going to work, but is it efficient? Looking into the Apple Doc...

Sep 14, 2022 · 1 min read · ahmedelgendy.com  
Read the article

-   [#swift](https://hashnode.com/tag/swift)
-   [#swiftsyntax](https://hashnode.com/tag/swiftsyntax)

## Written by

[Ahmed Elgendy](https://hashnode.com/@ahmedelgendy)

@ahmedelgendy · Istanbul

  
[View profile](https://hashnode.com/@ahmedelgendy)

iOS Software Engineer

iOS Software Engineer (Swift, SwiftUI) with +4 years of experience working with international teams and clients, Published +10 apps, seeking to build world-class apps

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
