Documentation Language: Swift

Function

max(_:_:)

Returns the maximum of two numeric values (OCL Integer/Real.max()).

func max(_ left: any EcoreValue, _ right: any EcoreValue) throws -> any EcoreValue

Parameters

left

The first numeric value

right

The second numeric value

Return Value

The maximum of the two values

Discussion

Compares two numeric values and returns the larger one. Follows OCL type coercion rules: Integer conformsTo Real.

Type Coercion Rules

Examples

let result1 = try max(5 as EInt, 3 as EInt)         // Result: 5 as EInt
let result2 = try max(2.5 as EDouble, 3.1 as EDouble) // Result: 3.1 as EDouble
let result3 = try max(7 as EInt, 6.5 as EDouble)    // Result: 7.0 as EDouble