lambda
lambda
语法糖
::
- 静态类方法
- 类::静态类方法
- 会被优化成这个
- 类::静态类方法
class::staticMethod
(item)->{class.staticMethod(item)}
- 实例方法
- 实例::方法
- 会被优化成这个
- 实例::方法
instance::method
(item)->{instance.method(item)} ///使用instance去调用方法
- 类方法(非静态)
- 类::方法
- 会被优化成这个
- 类::方法
class::method
(item,item2)->{item.method(item2)}
//会使用第一个参数去调用方法,如果这个参数里面没有这个方法,编译器会报错
//所以,这个class一定是item的类class,而不能是别的class
- 构造方法
- 类::构造方法
- 会被优化成这个
- 类::构造方法
class::new
(item...)->{new class(item...)}
//根据传入的参数自动匹配构造方法
更新: 2025-11-25 22:10:20
原文: https://www.yuque.com/duifangzhengzaishuru-rqbua/axyc58/xs3kzcq79qfzr1iz