---
title: "count(_:)"
framework: foundationmodels
role: symbol
role_heading: Type Method
path: "foundationmodels/generationguide/count(_:)"
---

# count(_:)

Enforces that the array has exactly a certain number elements.

## Declaration

```swift
static func count<Element>(_ count: Int) -> GenerationGuide<[Element]> where Value == [Element]
```

## Discussion

Discussion A count generation guide may be used when you want to ensure the model produces exactly a certain number array elements, such as the number of items in a game’s shop. @Generable struct Shop {     @Guide(description: "A creative name for a shop in a fantasy RPG")     var name: String

@Guide(description: "A list of items for sale", .count(3))     var inventory: [ShopItem] }
