🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
### [操作符和特殊符号](http://www.kotlincn.net/docs/reference/keyword-reference.html#操作符和特殊符号) Kotlin 支持以下操作符和特殊符号: * `+`、`-`、`*`、`/`、`%`—— 数学操作符 * `*`也用于[将数组传递给 vararg 参数](http://www.kotlincn.net/docs/reference/functions.html#可变数量的参数varargs) * `=` * 赋值操作符 * 也用于指定[参数的默认值](http://www.kotlincn.net/docs/reference/functions.html#默认参数) * `+=`、`-=`、`*=`、`/=`、`%=`——[广义赋值操作符](http://www.kotlincn.net/docs/reference/operator-overloading.html#assignments) * `++`、`--`——[递增与递减操作符](http://www.kotlincn.net/docs/reference/operator-overloading.html#递增与递减) * `&&`、`||`、`!`—— 逻辑“与”、“或”、“非”操作符(对于位运算,请使用相应的[中缀函数](http://www.kotlincn.net/docs/reference/basic-types.html#运算)) * `==`、`!=`——[相等操作符](http://www.kotlincn.net/docs/reference/operator-overloading.html#equals)(对于非原生类型会翻译为调用`equals()`) * `===`、`!==`——[引用相等操作符](http://www.kotlincn.net/docs/reference/equality.html#引用相等) * `<`、`>`、`<=`、`>=`——[比较操作符](http://www.kotlincn.net/docs/reference/operator-overloading.html#comparison)(对于非原生类型会翻译为调用`compareTo()`) * `[`、`]`——[索引访问操作符](http://www.kotlincn.net/docs/reference/operator-overloading.html#indexed)(会翻译为调用`get`与`set`) * `!!`[断言一个表达式非空](http://www.kotlincn.net/docs/reference/null-safety.html#-操作符) * `?.`执行[安全调用](http://www.kotlincn.net/docs/reference/null-safety.html#安全的调用)(如果接收者非空,就调用一个方法或访问一个属性) * `?:`如果左侧的值为空,就取右侧的值([elvis 操作符](http://www.kotlincn.net/docs/reference/null-safety.html#elvis-操作符)) * `::`创建一个[成员引用](http://www.kotlincn.net/docs/reference/reflection.html#函数引用)或者一个[类引用](http://www.kotlincn.net/docs/reference/reflection.html#类引用) * `..`创建一个[区间](http://www.kotlincn.net/docs/reference/ranges.html) * `:`分隔声明中的名称与类型 * `?`将类型标记为[可空](http://www.kotlincn.net/docs/reference/null-safety.html#可空类型与非空类型) * `->` * 分隔[lambda 表达式](http://www.kotlincn.net/docs/reference/lambdas.html#lambda-表达式语法)的参数与主体 * 分隔在[函数类型](http://www.kotlincn.net/docs/reference/lambdas.html#函数类型)中的参数类型与返回类型声明 * 分隔[when 表达式](http://www.kotlincn.net/docs/reference/control-flow.html#when-表达式)分支的条件与代码体 * `@` * 引入一个[注解](http://www.kotlincn.net/docs/reference/annotations.html#用法) * 引入或引用一个[循环标签](http://www.kotlincn.net/docs/reference/returns.html#break-与-continue-标签) * 引入或引用一个[lambda 表达式标签](http://www.kotlincn.net/docs/reference/returns.html#标签处返回) * 引用一个来自外部作用域的[“this”表达式](http://www.kotlincn.net/docs/reference/this-expressions.html#限定的-this) * 引用一个[外部超类](http://www.kotlincn.net/docs/reference/classes.html#调用超类实现) * `;`分隔位于同一行的多个语句 * `$`在[字符串模版](http://www.kotlincn.net/docs/reference/basic-types.html#字符串模板)中引用变量或者表达式 * `_` * 在[lambda 表达式](http://www.kotlincn.net/docs/reference/lambdas.html#下划线用于未使用的变量自-11-起)中代替未使用的参数 * 在[解构声明](http://www.kotlincn.net/docs/reference/multi-declarations.html#下划线用于未使用的变量自-11-起)中代替未使用的参数 ### 操作符的优先级 ![](https://box.kancloud.cn/3bc31e9be6dba3fbe69e2afd9b7b81a7_906x779.png)