当前位置:网站首页>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)
* }
*/
边栏推荐
猜你喜欢
让Livelink初始Pose与动捕演员一致
Myabtis_ Plus
【數字IC驗證快速入門】15、SystemVerilog學習之基本語法2(操作符、類型轉換、循環、Task/Function...內含實踐練習)
在Rainbond中实现数据库结构自动化升级
Don't stop chasing the wind and the moon. Spring mountain is at the end of Pingwu
漏洞复现-Fastjson 反序列化
buureservewp(2)
Fast parsing intranet penetration escorts the document encryption industry
Use of JMeter
Codeforce c.strange test and acwing
随机推荐
运放电路的反馈电阻上并联一个电容是什么作用
JS quick start (I)
追风赶月莫停留,平芜尽处是春山
Topic not received? Try this
Empire CMS collection Empire template program general
[quick start of Digital IC Verification] 10. Verilog RTL design must know FIFO
Use of JMeter
快解析内网穿透为文档加密行业保驾护航
Qinglong panel -- Huahua reading
互动送书-《Oracle DBA工作笔记》签名版
ZCMU--1492: Problem D(C语言)
It's too true. There's a reason why I haven't been rich
Content of string
Easy to understand SSO
Hisense TV starts the developer mode
一文了解如何源码编译Rainbond基础组件
Pytoch (VI) -- model tuning tricks
game攻防世界逆向
Relevant data of current limiting
[untitled]