当前位置:网站首页>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)
* }
*/边栏推荐
- 央视太暖心了,手把手教你写HR最喜欢的简历
- 漏洞复现-easy_tornado
- Recursive method to verify whether a tree is a binary search tree (BST)
- CDC (change data capture technology), a powerful tool for real-time database synchronization
- 一文了解如何源码编译Rainbond基础组件
- 电池、电机技术受到很大关注,反而电控技术却很少被提及?
- 快解析内网穿透助力外贸管理行业应对多种挑战
- Vulnerability recurrence easy_ tornado
- Minimum absolute difference of binary search tree (use medium order traversal as an ordered array)
- 王爽 《汇编语言》之寄存器
猜你喜欢

机器人教育在动手实践中的真理

通俗易懂单点登录SSO
![[quick start of Digital IC Verification] 12. Introduction to SystemVerilog testbench (svtb)](/img/dc/a809f2ec5f9e85a02e68c88bdcdb5e.png)
[quick start of Digital IC Verification] 12. Introduction to SystemVerilog testbench (svtb)

追风赶月莫停留,平芜尽处是春山

【数字IC验证快速入门】13、SystemVerilog interface 和 program 学习

LeetCode中等题之我的日程安排表 I

Codeforce c.strange test and acwing

JS复制图片到剪切板 读取剪切板

【数字IC验证快速入门】11、Verilog TestBench(VTB)入门

复杂网络建模(一)
随机推荐
让Livelink初始Pose与动捕演员一致
Interactive book delivery - signed version of Oracle DBA work notes
柯基数据通过Rainbond完成云原生改造,实现离线持续交付客户
王爽 《汇编语言》之寄存器
Quick analysis of Intranet penetration helps the foreign trade management industry cope with a variety of challenges
【踩坑系列】uniapp之h5 跨域的问题
青龙面板--整理能用脚本
[quickstart to Digital IC Validation] 15. Basic syntax for SystemVerilog Learning 2 (operator, type conversion, loop, Task / Function... Including practical exercises)
Notes on PHP penetration test topics
探索STEAM艺术设计中的创造力
Dedecms collects content without writing rules
Leetcode medium question my schedule I
Recursive construction of maximum binary tree
Zcmu--1492: problem d (C language)
buureservewp(2)
轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷
Unityhub cracking & unity cracking
LeetCode简单题之判断一个数的数字计数是否等于数位的值
Vulnerability recurrence fastjson deserialization
Fast parsing intranet penetration escorts the document encryption industry