Function
min(_:_:)
Returns the minimum of two numeric values (OCL Integer/Real.min()).
func min(_ left: any EcoreValue, _ right: any EcoreValue) throws -> any EcoreValue
Parameters
left-
The first numeric value
right-
The second numeric value
Return Value
The minimum of the two values
Discussion
Compares two numeric values and returns the smaller one. Follows OCL type coercion rules: Integer conformsTo Real.
Type Coercion Rules
-
Integer types (EByte, EShort, EInt, ELong) promote to largest type
-
Real types (EFloat, EDouble, EBigDecimal) promote to most precise type
-
Integer + Real → Real (Integer promoted to Real)
Examples
let result1 = try min(5 as EInt, 3 as EInt) // Result: 3 as EInt
let result2 = try min(2.5 as EDouble, 3.1 as EDouble) // Result: 2.5 as EDouble
let result3 = try min(7 as EInt, 6.5 as EDouble) // Result: 6.5 as EDouble