Kotlin Standart函数
来源:互联网 发布:sql 时间戳转换成时间 编辑:程序博客网 时间:2024/05/21 16:35
- TODO
- run
- with
- apply
- also
- let
- takeIf
- takeUnless
- repeat
Standard.kt文件下
TODO()
/** * An exception is thrown to indicate that a method body remains to be implemented. */public class NotImplementedError(message: String = "An operation is not implemented.") : Error(message)/** * Always throws [NotImplementedError] stating that operation is not implemented. */@kotlin.internal.InlineOnlypublic inline fun TODO(): Nothing = throw NotImplementedError()/** * Always throws [NotImplementedError] stating that operation is not implemented. * * @param reason a string explaining why the implementation is missing. */@kotlin.internal.InlineOnlypublic inline fun TODO(reason: String): Nothing = throw NotImplementedError("An operation is not implemented: $reason")
run()
/** * Calls the specified function [block] and returns its result. */@kotlin.internal.InlineOnlypublic inline fun <R> run(block: () -> R): R = block()/** * Calls the specified function [block] with `this` value as its receiver and returns its result. */@kotlin.internal.InlineOnlypublic inline fun <T, R> T.run(block: T.() -> R): R = block()
with()
/** * Calls the specified function [block] with the given [receiver] as its receiver and returns its result. */@kotlin.internal.InlineOnlypublic inline fun <T, R> with(receiver: T, block: T.() -> R): R = receiver.block()
apply()
/** * Calls the specified function [block] with `this` value as its receiver and returns `this` value. */@kotlin.internal.InlineOnlypublic inline fun <T> T.apply(block: T.() -> Unit): T { block(); return this }
also()
/** * Calls the specified function [block] with `this` value as its argument and returns `this` value. */@kotlin.internal.InlineOnly@SinceKotlin("1.1")public inline fun <T> T.also(block: (T) -> Unit): T { block(this); return this }
let()
/** * Calls the specified function [block] with `this` value as its argument and returns its result. */@kotlin.internal.InlineOnlypublic inline fun <T, R> T.let(block: (T) -> R): R = block(this)
takeIf()
/** * Returns `this` value if it satisfies the given [predicate] or `null`, if it doesn't. */@kotlin.internal.InlineOnly@SinceKotlin("1.1")public inline fun <T> T.takeIf(predicate: (T) -> Boolean): T? = if (predicate(this)) this else null
takeUnless()
/** * Returns `this` value if it _does not_ satisfy the given [predicate] or `null`, if it does. */@kotlin.internal.InlineOnly@SinceKotlin("1.1")public inline fun <T> T.takeUnless(predicate: (T) -> Boolean): T? = if (!predicate(this)) this else null
repeat()
/** * Executes the given function [action] specified number of [times]. * * A zero-based index of current iteration is passed as a parameter to [action]. */@kotlin.internal.InlineOnlypublic inline fun repeat(times: Int, action: (Int) -> Unit) { for (index in 0..times - 1) { action(index) }}
阅读全文
0 0
- Kotlin Standart函数
- Kotlin 函数
- Kotlin-函数
- Kotlin -- 函数
- Kotlin-函数
- Kotlin函数
- Kotlin学习之函数
- Kotlin构造函数
- Kotlin函数相关介绍
- Kotlin-内联函数
- Kotlin 创建 main 函数
- kotlin--类与函数
- kotlin汇总6-函数
- Kotlin基础教程-函数
- kotlin 函数(一)
- android kotlin扩展函数
- Kotlin基础教程-内联函数
- kotlin入门(八)函数
- 通过事件通知 实现react.js组件间通信
- 文章标题
- 初识docker—创建WEB应用容器1python+flask
- 三色国旗问题,
- Handler内存泄漏分析及解决
- Kotlin Standart函数
- shell分割参数为数组并循环执行jar,异常时退出循环
- Spring Cloud微服务架构在互联网中应用|Spring Cloud视频教程下载
- AngularJs简单数据的添加
- 第六章 布局管理
- 分别使用JQ和JS实现定时弹窗
- JS检测微信返回按钮事件
- Python numpy随机数生成和数学统计运算[转]
- 第一章 绪论