<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-to-declare-a-fixed-size-array-in-swift-lnmnhrh4e" -->

---
title: How to declare a fixed-size array in Swift | daily.dev
description: Swift 6.2 introduces InlineArray, a fixed-size array whose length is encoded in its type, storing elements inline (on the stack or in the enclosing struct)...
canonical: https://daily.dev/posts/how-to-declare-a-fixed-size-array-in-swift-lnmnhrh4e
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How to declare a fixed-size array in Swift | daily.dev
og:description: Swift 6.2 introduces InlineArray, a fixed-size array whose length is encoded in its type, storing elements inline (on the stack or in the enclosing struct)...
og:url: https://daily.dev/posts/how-to-declare-a-fixed-size-array-in-swift-lnmnhrh4e
og:image: https://api.daily.dev/og/posts/lnmnHrH4e.png
og:image:alt: How to declare a fixed-size array in Swift
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How to declare a fixed-size array in Swift

**[Sarunw](https://daily.dev/sources/sarunw)** · [@sarunw](https://daily.dev/sarunw) · 5 min read · 0 upvotes · 0 comments

## Summary

Swift 6.2 introduces InlineArray, a fixed-size array whose length is encoded in its type, storing elements inline (on the stack or in the enclosing struct) rather than on the heap. SE-0483 adds bracket shorthand [5 of Int] as sugar for InlineArray<5, Int>, resolved entirely at compile time with no ABI or runtime impact. The syntax supports inference with underscores, nests as expected, and requires whitespace around 'of'. InlineArray does not conform to Collection or ExpressibleByArrayLiteral despite literal syntax working through a compiler special case, and a value-level shorthand like [5 of 99] remains a future direction, not yet available.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://sarunw.com/posts/fixed-size-array-in-swift>

## Questions this post answers

### How do I declare a fixed-size array in Swift 6.2?

Use InlineArray, whose length is part of its type, e.g. InlineArray<5, Int>, or the shorthand [5 of Int] introduced by SE-0483. Both forms produce the same type, are resolved at compile time, and store elements inline (on the stack or in the enclosing struct) instead of on the heap, unlike the standard Array type.

_Developers adopting Swift 6.2 features can track syntax changes like this one on daily.dev._

### Does Swift's InlineArray conform to the Collection protocol?

No, InlineArray does not conform to Collection; the standard library deliberately withheld that conformance, so typical collection methods are unavailable. It does expose an indices property, so looping with a for-in over numbers.indices still works even without full collection support.

_Swift developers weighing new type behaviors like this can follow the details on daily.dev._

### Can I write a fixed-size array literal like [5 of 99] in Swift?

Not yet. The value-form shorthand [5 of 99], which would let you write repeated values directly, is listed only as a future direction in SE-0483, requiring a new expressible-by-literal protocol design. For now, repeated values must go through an initializer, such as InlineArray<5, Int>.init(repeating: 99) or the type-shorthand equivalent.

_Those tracking upcoming Swift language proposals can watch this space on daily.dev._

## Similar posts on daily.dev

- [Trailing commas beyond arrays in Swift 6.1](https://daily.dev/posts/trailing-commas-beyond-arrays-in-swift-6-1-hdz8a4yaz) · Sarunw · 0 upvotes · 0 comments

---

Tags: [#swift](https://daily.dev/tags/swift)

[View this post on daily.dev](https://daily.dev/posts/how-to-declare-a-fixed-size-array-in-swift-lnmnhrh4e)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"How to declare a fixed-size array in Swift","url":"https://daily.dev/posts/how-to-declare-a-fixed-size-array-in-swift-lnmnhrh4e","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-to-declare-a-fixed-size-array-in-swift-lnmnhrh4e"},"datePublished":"2026-09-01T11:58:29.998Z","dateModified":"2026-09-02T08:00:27.544Z","description":"Swift 6.2 introduces InlineArray, a fixed-size array whose length is encoded in its type, storing elements inline (on the stack or in the enclosing struct)...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/a57fae8374aa851004c630e51c5dba8e?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/a57fae8374aa851004c630e51c5dba8e?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Sarunw","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Person","name":"Sarun Wongpatcharapakorn","url":"https://daily.dev/sarunw","image":"https://avatars.githubusercontent.com/u/795368?v=4","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":20}},"commentCount":0,"discussionUrl":"https://daily.dev/posts/how-to-declare-a-fixed-size-array-in-swift-lnmnhrh4e","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"swift","timeRequired":"PT5M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Sarunw","item":"https://daily.dev/sources/sarunw"},{"@type":"ListItem","position":3,"name":"How to declare a fixed-size array in Swift"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/how-to-declare-a-fixed-size-array-in-swift-lnmnhrh4e#faq","mainEntity":[{"@type":"Question","name":"How do I declare a fixed-size array in Swift 6.2?","acceptedAnswer":{"@type":"Answer","text":"Use InlineArray, whose length is part of its type, e.g. InlineArray<5, Int>, or the shorthand [5 of Int] introduced by SE-0483. Both forms produce the same type, are resolved at compile time, and store elements inline (on the stack or in the enclosing struct) instead of on the heap, unlike the standard Array type. Developers adopting Swift 6.2 features can track syntax changes like this one on daily.dev."}},{"@type":"Question","name":"Does Swift's InlineArray conform to the Collection protocol?","acceptedAnswer":{"@type":"Answer","text":"No, InlineArray does not conform to Collection; the standard library deliberately withheld that conformance, so typical collection methods are unavailable. It does expose an indices property, so looping with a for-in over numbers.indices still works even without full collection support. Swift developers weighing new type behaviors like this can follow the details on daily.dev."}},{"@type":"Question","name":"Can I write a fixed-size array literal like [5 of 99] in Swift?","acceptedAnswer":{"@type":"Answer","text":"Not yet. The value-form shorthand [5 of 99], which would let you write repeated values directly, is listed only as a future direction in SE-0483, requiring a new expressible-by-literal protocol design. For now, repeated values must go through an initializer, such as InlineArray<5, Int>.init(repeating: 99) or the type-shorthand equivalent. Those tracking upcoming Swift language proposals can watch this space on daily.dev."}}]}
```

