当前位置:网站首页>Standard function let and generic extension function in kotlin
Standard function let and generic extension function in kotlin
2022-07-07 08:14:00 【yu-Knight】
fun main() {
"yuknight".mLet {
it
true
"Ok"
}
123.mLet {
it
}
val str = "str".let {
it
}
}
//fun<I, O> In the function , Declare two generics , Function type ,I Input parameters ,O Function return value
//I.mLet Yes I Input parameters for extension , The extension function name is mLet, It means that all types can call this function
//lambda:(I)->O (I Input parameters )->O Return value
//:O The return value of the function will change according to the user's return type
//lambda(this) I Function extension , In the whole extension function ,this == I Oneself
private inline fun <I, O> I.mLet(lambda: (I) -> O) = lambda(this)
/**
* private inline fun <I, O> I.mLet(lambda: (I) -> O): O {
* lambda(this)
* }
*/
//let Function source code
/**
* public inline fun <T, R> T.let(block: (T) -> R): R {
* return block(this)
* }
*/
边栏推荐
- UnityHub破解&Unity破解
- Fast parsing intranet penetration escorts the document encryption industry
- It's too true. There's a reason why I haven't been rich
- 在 Rainbond 中一键安装高可用 Nacos 集群
- 青龙面板--整理能用脚本
- 面试题(CAS)
- It took "7" years to build the robot framework into a micro service
- 【Go ~ 0到1 】 第七天 获取时间戳,时间比较,时间格式转换,Sleep与定时器
- buureservewp(2)
- Introduction à l'objet blob
猜你喜欢
云原生存储解决方案Rook-Ceph与Rainbond结合的实践
青龙面板-今日头条
Network learning (II) -- Introduction to socket
[quick start of Digital IC Verification] 15. Basic syntax of SystemVerilog learning 2 (operators, type conversion, loops, task/function... Including practical exercises)
解析创新教育体系中的创客教育
复杂网络建模(一)
Network learning (III) -- highly concurrent socket programming (epoll)
game攻防世界逆向
Myabtis_Plus
Don't stop chasing the wind and the moon. Spring mountain is at the end of Pingwu
随机推荐
饥荒云服管理脚本
Basic use of CTF web shrink template injection nmap
Network learning (I) -- basic model learning
Leetcode 187 Repeated DNA sequence (2022.07.06)
B. Value sequence thinking
Dedecms collects content without writing rules
Qinglong panel -- finishing usable scripts
OpenVSCode云端IDE加入Rainbond一体化开发体系
[quick start of Digital IC Verification] 10. Verilog RTL design must know FIFO
uniapp 移动端强制更新功能
【數字IC驗證快速入門】15、SystemVerilog學習之基本語法2(操作符、類型轉換、循環、Task/Function...內含實踐練習)
Rainbond 5.6 版本发布,增加多种安装方式,优化拓扑图操作体验
Recursive method to construct binary tree from preorder and inorder traversal sequence
雅思考试自己的复习进度以及方法使用【日更版】
CTF-WEB shrine模板注入nmap的基本使用
CCTV is so warm-hearted that it teaches you to write HR's favorite resume hand in hand
【雅思口语】安娜口语学习记录 Part3
[quick start of Digital IC Verification] 14. Basic syntax of SystemVerilog learning 1 (array, queue, structure, enumeration, string... Including practical exercises)
解读创客思维与数学课程的实际运用
机器人教育在动手实践中的真理