Documentation Language: Swift

Function

size(_:)

Returns the number of elements in a collection or characters in a string.

func size(_ value: any EcoreValue) throws -> EInt

Parameters

value

The collection or string to measure

Return Value

The size as an integer

Discussion

The size operation works with collections, strings, and wrapped arrays. For collections, it returns the element count. For strings, it returns the character count.

Examples

let numbers = [1, 2, 3] as [EInt]
let count = try size(numbers)  // Result: 3

let text = "Hello" as EString
let length = try size(text)    // Result: 5