# How for \`SwiftUI.ForEach.init(\_ data: Range\<Int\>, @ViewBuilder content: @escaping (Int) -\> Content)\` compiler is able to warn if \`Range\` is not constant?

**URL:** <https://forums.swift.org/t/how-for-swiftui-foreach-init-data-range-int-viewbuilder-content-escaping-int-content-compiler-is-able-to-warn-if-range-is-not-constant/55233>\
**Category:** Using Swift\
**Created:** [February 10, 2022, 1:52am UTC](https://forums.swift.org/t/how-for-swiftui-foreach-init-data-range-int-viewbuilder-content-escaping-int-content-compiler-is-able-to-warn-if-range-is-not-constant/55233 "2022-02-10T01:52:44Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![t8n](https://avatars.discourse-cdn.com/v4/letter/t/a587f6/32.png) [@t8n](https://forums.swift.org/u/t8n)\
**Post date:** [March 15, 2022, 3:45am UTC](https://forums.swift.org/t/how-for-swiftui-foreach-init-data-range-int-viewbuilder-content-escaping-int-content-compiler-is-able-to-warn-if-range-is-not-constant/55233/4 "2022-03-15T03:45:48Z")

</div>

I'm getting this warning with Xcode 13.3

`let kLoops = 6`

and then in a view:

`ForEach(0..<kLoops) {`

And getting: `Non-constant range: argument must be an integer literal`

Am I doing anything wrong? Or is there a way to suppress this warning?

---

_[View the full topic](https://forums.swift.org/t/how-for-swiftui-foreach-init-data-range-int-viewbuilder-content-escaping-int-content-compiler-is-able-to-warn-if-range-is-not-constant/55233)._
