操作符函数

下表列出了仓颉支持的所有操作符函数。

操作符函数函数签名示例
[] (索引取值)operator func [](index1: T1, index2: T2, ...): Rthis[index1, index2, ...]
[] (索引赋值)operator func [](index1: T1, index2: T2, ..., value!: TN): Rthis[index1, index2, ...] = value
()operator func ()(param1: T1, param2: T2, ...): Rthis(param1, param2, ...)
!operator func !(): R!this
**operator func **(other: T): Rthis ** other
*operator func *(other: T): Rthis * other
/operator func /(other: T): Rthis / other
%operator func %(other: T): Rthis % other
+operator func +(other: T): Rthis + other
-operator func -(other: T): Rthis - other
<<operator func <<(other: T): Rthis << other
>>operator func >>(other: T): Rthis >> other
<operator func <(other: T): Rthis < other
<=operator func <=(other: T): Rthis <= other
>operator func >(other: T): Rthis > other
>=operator func >=(other: T): Rthis >= other
==operator func ==(other: T): Rthis == other
!=operator func !=(other: T): Rthis != other
&operator func &(other: T): Rthis & other
^operator func ^(other: T): Rthis ^ other
|operator func |(other: T): Rthis | other