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

# maximumCount(_:)

Enforces a maximum number of elements in the array.

## Declaration

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

## Mentioned in

Categorizing and organizing data with content tags Managing the context window

## Discussion

Discussion The bounds are inclusive. A maximumCount generation guide may be used when you want to ensure the model produces a number of array elements less than or equal to to some maximum value, 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", .maximumCount(10))     var inventory: [ShopItem] }

## See Also

### Getting the maximum value

- [maximum(_:)](foundationmodels/generationguide/maximum(_:).md)
