我有以下代码Scala的功能:呼叫内的可变
def func1 : Mylass = ...
def func2 : Mylass = ...
def func3 : Mylass = ...
def function : List[MyClass] = {
val funcs = List(func1, func2, func3)
for {
f <- funcs
result = [??? What I shall put here ???]
} yield result
}
for循环的目的是调用通过一个存储的内部f
一个的功能。但我不知道我要放什么来“调用存储在变量f
内部的函数”。
我试图把:
result = f()
但我的IDE提供了编译错误。
非常感谢。
如果for理解是在一个函数内部,并且签名像他提供的那样,那么它就不会编译。 – pedromss
当然,它确实...我会更新答案 – Dima
请注意'='而不是'< - '它很微妙,他可能看不到它。同样,如果在'yield'子句中使用'='可能也是 – pedromss