Documentation Language: Swift

Function

includes(_:_:)

Tests whether a collection contains a specific element.

func includes(_ collection: any EcoreValue, _ element: any EcoreValue) throws -> Bool

Parameters

collection

The collection to search in

element

The element to search for

Return Value

true if the element is found, false otherwise

Discussion

The includes operation returns true if the element is present in the collection, using equality comparison.

Examples

let numbers = [1, 2, 3] as [EInt]
let hasTwo = try includes(numbers, 2 as EInt)  // Result: true