0
如何将匿名函数的结果作为参数发送到另一个函数中?Scala如何发送匿名函数结果作为参数
举个例子:
object TestThisFunction {
def getString(): String = {
"foo"
}
def useString(foo: String) = {
println(foo + "bar")
}
useString("foo");
useString(getString());
// This does not work: type mismatch; found :() => String required: String
useString(() => {
"foo"
})
}
有一些语法,将使用匿名函数作出useString最后调用()的工作?
谢谢你的时间。创建后