![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Kotlin
文章平均质量分 76
鸡蛋卷啊卷
这个作者很懒,什么都没留下…
展开
-
【Kotlin suspend coroutines 原理,代码转为状态机,粗略笔记】
结论 kotlin的suspend coroutines,为简化 异步代码 的书写,compiler处理异步回调。 程序员注明异步的method ,以 direct call形式编码 compiler生成 回调,并以 状态机 调用 如视频所说,没有magic。类比于用 中文写程序,中文是宏命令啥的。(个人臆测) 我了解的点 compiler帮你用 回调书写异步代码 compiler将你的code,翻译成状态机,来运行、暂停你的代码 。 相当于用关键字 suspend、await 告诉compiler,原创 2021-03-06 12:50:00 · 499 阅读 · 0 评论 -
Kotlin null safe let run also apply with return
如何正确使用 ?. ?: let来避免空指针,并简化书写 Java的错误示例 //*** private WeakReference<TextureView> textureViewReference; @Override public int getWidth() { return textureViewReference.get()...原创 2020-04-29 14:49:26 · 221 阅读 · 0 评论 -
Kotlin !! ?可空性问题
Context private var mDisplayView: TextView? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_...原创 2018-06-21 18:29:05 · 495 阅读 · 0 评论 -
kotlin function: run with let also apply
Scoping functions (作用域 函数) 提供了一个 内部独立的区间(也就是方法的上下文 如下的run方法) run{} 提供独立上下文 with(T){} 上下文为参数 T.run{} 对比with(T) T.run{}是个拓展方法 extension function,默认参数是T. 就是T相当于方法内部(作用域内)的this T.let{} 默认参数是T 就是T...翻译 2018-08-13 18:34:36 · 190 阅读 · 0 评论