当前位置:网站首页>On the closure function of Scala
On the closure function of Scala
2022-06-22 16:57:00 【ZH519080】
object Closure {
/**scala Closure is a function : A variable inside a function is not when it acts on , It can still be accessed from outside .
* The process of defining a closure function is to capture the free variables outside the function and form a closed function .
* When a variable outside a function changes ,scala The closure of can capture the change of variables ,
* scala Closures capture the variable itself, not its value */
// Application of closure function , Dependent on variables y, Reference to function closure01 Variables defined outside y
def closure01(x: Double) = (y: Int) => x*y
// And closure01 The function is the same ,closure02 The return value of depends on external variables y. Reference to function closure02 Variables defined outside y
var y = 2
def closure02(x: Int) = x*y
def main(args: Array[String]): Unit = {
val closureValue: Int => Double = closure01(3.5)
println(closure02(4))
println(closureValue(3))
}
}
边栏推荐
- [C language] use of library function qsort
- Implementing factory mode using enumeration
- 同花顺怎么开户?网上开户安全么?
- How to open an account in flush? Is it safe to open an account online?
- Summary of safari compatibility issues
- Task scheduling design of collection system
- 【微信小程序封装底部弹出框二】
- 同花顺是什么?在线开户安全么?
- 图计算Hama-BSP模型的运行流程
- JSP学习之开发模式
猜你喜欢
![[wechat applet custom bottom tabbar]](/img/04/2ea4ab3fd8571499190a9b3c9990b2.png)
[wechat applet custom bottom tabbar]

LETV group payment system architecture sharing for processing 100000 high concurrent orders per second

华为云招募工业智能领域合作伙伴,强力扶持+商业变现

短视频源码开发,优质的短视频源码需要做好哪几点?

Qt笔记-QMap自定义键(key)

Shell learning

超出文本部分用省略号表示
![[Alibaba cloud server - install MySQL version 5.6 and reinstall]](/img/5a/50b1de5f58235f6d11f6ad1eecc455.png)
[Alibaba cloud server - install MySQL version 5.6 and reinstall]

Vhedt business development framework

In the era of video explosion, who is supporting the high-speed operation of video ecological network?
随机推荐
JS获取数据类型方法总结
接口(优化类型注解)
大话局部性原理
每秒处理10万高并发订单的乐视集团支付系统架构分享
为数字添加千分位符号(金额千分位)
Safari兼容性问题总结
uniapp微信小程序获取页面二维码(带有参数)
NiO uses writable events to handle the situation of one-time write incompleteness
让代码优雅起来(学会调试+代码风格)
How to add a "security lock" to the mobile office of government and enterprises?
超出文本部分用省略号表示
Vhedt business development framework
招行23型号UKey在win7上无法识别
[MYSQL]一台windows电脑安装多个mysql-不同版本
为什么要买增额终身寿险?增额终身寿险安全可靠吗?
【阿里云服务器-安装mysql的5.6版本安装,重装】
Vs2017 solution to not displaying qstring value in debugging status
华为云招募工业智能领域合作伙伴,强力扶持+商业变现
In the era of video explosion, who is supporting the high-speed operation of video ecological network?
Web technology sharing | [Gaode map] to realize customized track playback