val a: Int = 1;类型推断fun f(x: Int): Int = x + 1;默认/命名参数"Hello $name" 与 "${expr}"String?、?.、?:、!!""" ... """ 多行 + trimIndent/trimMargin== 结构相等,=== 引用相等const val 仅顶层或 object/伴生typealias UserId = Stringimport 支持 as 重命名when 表达式支持类型/范围/条件分支,返回值友好1..10、downTo、step、untillistOf/mutableListOf;map/filter/flatMap/groupByval (a,b) = pair;数据类提供 componentNfor ((i,v) in list.withIndex())、repeat(n)return@label/break@label/continue@labelval v = try { parse() } catch(e:Exception){ -1 }data class User(val id:Int, val name:String)sealed class / sealed interface 表达 ADTobject 单例;companion object 伴生对象fun String.title(): String = ...;属性与运算符重载init;次构造需 this(...) 链接get()/set() 自定义;field 引用后备字段public/internal/protected/privateopen/final/abstract;接口可含默认实现nested(静态) vs inner(持外部引用)lateinit var 与 by lazy { }out 协变、in 逆变;边界 <T: Number>inline fun <reified T> parse(..) 直接使用 T::classinline、noinline、crossinlinelet/apply/also/run/with 选型与返回值对比MutableList<out T>/in T 限制读写List<*>;多重约束:where T: A, T: Binline 可用;crossinline 禁止is T 检查、Json.decodeFromString<T>(s)CoroutineScope + SupervisorJob;结构化并发launch/async;withContext(Dispatchers.IO)isActive;withTimeout 超时flow { emit(..) };debounce/mapLatest/combinecoroutineScope vs supervisorScope(失败隔离)CoroutineExceptionHandler;结构化传播flowOn 切换上游线程;buffer/conflatecatch/retryWhen/onCompletionStateFlow/SharedFlow 与 stateIn/shareInclass C(b: B) : B by b 组合优先@JvmInline value class 轻量包装(避免装箱)by lazy、Delegates.observableDelegates.vetoable 拦截写入class User(map: Map<String,Any>){ val name: String by map }String?;安全调用:?.;Elvis:?:as?;非空断言:!!(避免滥用)is 判定后自动 smart cast!!,建议检查a?.b?.c + let { } 安全使用val x = y ?: return/throwAny/Any?、Unit、Nothingrequire/check/error 报错与前置校验vararg;尾随 lambda(A) -> B;函数引用 ::footailrec fun fact(n:Int,...) 编译器优化String.(Int) -> Unit 作为回调::fun/Class::method/::prop*array;中缀:infix funfun String.words(): List<String>let(返回 lambda 结果)、also(返回接收者)、apply(配置对象)、run/withlet/run;需要返回接收者用 also/applyfun String?.isNullOrBlank()listOf/mutableListOf、mapOf/mutableMapOf、setOfsequence{}、asSequence();适合大数据链式map/filter/flatMap/groupBy/associate、zip/chunked/windowedtoMutableList/toList;持久化集合(kotlinx.collections.immutable)sequence { yield(...) }、generateSequenceasSequence().map{ }.filter{ }.toList()mapKeys/mapValues;onEach 调试out 协变(只读生产者)、in 逆变(只写消费者)List<*> 表示未知类型参数<T: Number>;多重边界 <T> where T: A, T: Binline fun <reified T> find():T? 直接使用 T::classreified 协助检查operator fun plus/compareTo/get/set 等componentN() 或数据类自动生成equals/hashCode/toString/copy 与解构infix fun 简化 DSL 表达(需单参数成员/扩展)in/contains、iterator、get/set 等when 穷尽匹配sealed class/interface 受限层级便于穷尽检查object 单例;companion object 伴生对象@JvmInline value class 轻量封装标量entries 列举when 无 else,更安全@Retention/@Target/@Repeatable 等元注解KClass、属性/函数引用;primaryConstructor 等@JvmOverloads/@JvmStatic/@JvmField 等互操作优化@field:/@get:/@param: 指定作用域@Serializable 数据类;Json 配置 ignoreUnknownKeys/encodeDefaultsJson.encodeToString(obj) / Json.decodeFromString<T>(str)@SerialName 重命名;@Transient 忽略;多态需注册Clock.System.now() 获取 Instant;LocalDate/LocalDateTimeTimeZone.currentSystemDefault();Instant.toLocalDateTime(tz)CoroutineExceptionHandler;结构化传播与 SupervisorJobviewModelScope/lifecycleScope(Android);withContext 切换 DispatcherChannel、StateFlow、SharedFlowbuffer/conflate/flowOn;终端操作 collectChannel(capacity),send/receive;produce 构建select { } 多源选择(实验/高级)replay 与粘性行为差异