Lamda 表达式与 CodeBlocks 非常相似,但不同之处在于它具有可选类型的参数和返回值。
您还可以在参数列表中指定参数类型,如第 3 个示例所示
DELEGATE Multiply(x AS REAL8) AS REAL8
FUNCTION Start AS VOID
LOCAL del AS Multiply
del := {e => e * e}
? del(1)
? del(2)
? del(3)
? del(4)
Console.ReadLine()
LOCAL dfunc AS System.Func<Double,Double>
dfunc := {x =>
? "square of", x
RETURN x^2
}
? dfunc(5)
LOCAL typed AS Multiply
typed := {x AS REAL8 =>
? "square of", x
RETURN x^2
}
? typed(6)
RETURN