简体   繁体   English

Scala-封闭吗?

[英]Scala - Is that a closure?

I am not sure whether the code I´ve just written can be called a closure, here it is: 我不确定我刚刚编写的代码是否可以称为闭包,这里是:

withExistingDataSource(dataSourceId, dataSource => checkDataSourceTypeAndFetchDataFromAgent(dataSource, theQuery))

See following the previous method signature: 请参阅以下先前的方法签名:

private def withExistingDataSource(dataSourceId: Long, success: DataSource => Result): Result

Can I state that: 我可以声明:

dataSource => checkDataSourceTypeAndFetchDataFromAgent(dataSource, theQuery) 

is a closure? 是关闭?

Yes it is. 是的。

The result of the function depends on the theQuery variable which is defined outside the function. 函数的结果取决于在函数外部定义的theQuery变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM