摘要:
1 类的扩展 Kotlin 提供了扩展类或接口的操作,而无需通过类继承或使用装饰器等设计模式,来为某个类添加一些额外的属性或函数,我们只需要通过一个被称为扩展的特殊声明来完成。通过这种机制,我们可以将那些第三方类不具备的功能强行进行扩展,方便我们的操作。 1.1 扩展内置类 1.1.1 扩展属性 阅读全文
![【Kotlin】扩展属性、扩展函数](https://img2024.cnblogs.com/blog/3135663/202404/3135663-20240408213256016-818420150.png)
摘要:
1 一元运算符函数 1.1 符号和函数 符号 函数 +a a.unaryPlus() -a a.unaryMinus() !a a.not() a++ a.dec() a-- a.inc() 1.2 案例 fun main() { var stu = Student("Tom", 13) print 阅读全文
![【Kotlin】运算符函数、解构函数、中缀函数](https://img2024.cnblogs.com/blog/3135663/202404/3135663-20240408212928472-1643760262.png)