# Conditional Compilation inside array initializer

**URL:** <https://forums.swift.org/t/conditional-compilation-inside-array-initializer/53792>\
**Category:** Using Swift\
**Created:** [November 30, 2021, 8:03pm UTC](https://forums.swift.org/t/conditional-compilation-inside-array-initializer/53792 "2021-11-30T20:03:18Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![ahti](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ahti/32/604_2.png) [@ahti](https://forums.swift.org/u/ahti)\
**Post date:** [November 30, 2021, 8:18pm UTC](https://forums.swift.org/t/conditional-compilation-inside-array-initializer/53792/2 "2021-11-30T20:18:31Z")

</div>

> [@Hacksaw](#):
>
> Is there any pretty way to do this?

Right now, not really. I think I'd go for something like this, which is quite a bit more verbose:

```swift
let lol: [String] = {
    var a = [
        "a",
    ]
    #if SOME_CONDITION
    a += ["x"]
    #endif
    a += ["y"]
    return a
}()

```

In the long run, the next revision of [SE-0330](https://forums.swift.org/t/se-0330-conditionals-in-collections/53375/22) is our best hope.

---

_[View the full topic](https://forums.swift.org/t/conditional-compilation-inside-array-initializer/53792)._
